ethers#Signature TypeScript Examples
The following examples show how to use
ethers#Signature.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: permit.ts From trident with GNU General Public License v3.0 | 5 votes |
export async function getPermitSignature(
wallet: Wallet,
token: ERC20Mock | ERC20PermitAllowedMock,
spender: string,
value: BigNumberish = constants.MaxUint256,
deadline = constants.MaxUint256,
permitConfig?: { nonce?: BigNumberish; name?: string; chainId?: number; version?: string }
): Promise<Signature> {
const [nonce, name, version, chainId] = await Promise.all([
permitConfig?.nonce ?? token.nonces(wallet.address),
permitConfig?.name ?? token.name(),
permitConfig?.version ?? "1",
permitConfig?.chainId ?? wallet.getChainId(),
]);
return splitSignature(
await wallet._signTypedData(
{
name,
version,
chainId,
verifyingContract: token.address,
},
{
Permit: [
{
name: "owner",
type: "address",
},
{
name: "spender",
type: "address",
},
{
name: "value",
type: "uint256",
},
{
name: "nonce",
type: "uint256",
},
{
name: "deadline",
type: "uint256",
},
],
},
{
owner: wallet.address,
spender,
value,
nonce,
deadline,
}
)
);
}