This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var web3 = require("web3"); | |
const ethSigUtil = require("@metamask/eth-sig-util"); | |
const { SignTypedDataVersion } = require("@metamask/eth-sig-util"); | |
const ethUtil = require("ethereumjs-util"); | |
async function permit(_web3, _USDCInstance) { | |
const usdcAddress = "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359"; | |
const privateKey = "..."; // owner's pk | |
const pkBuffer = Buffer.from(privateKey, "hex"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final msgParams = { | |
"types": { | |
"EIP712Domain": [ | |
{"type": "string", "name": "name"}, | |
{"type": "string", "name": "version"}, | |
{"type": "uint256", "name": "chainId"}, | |
{"type": "address", "name": "verifyingContract"} | |
], | |
"TransferWithAuthorization": [ | |
{"name": "from", "type": "address"}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See comment below with code example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Future<String?> signUSDC( | |
BigInt amount, Web3Dart.EthereumAddress ethAddress, User user) async { | |
final config = ref.read(configurationProvider).instance; | |
final wallet = Web3Dart.Wallet.fromJson(user.ethereumWallet!, kWalletPassword); | |
final validAfter = BigInt.zero; | |
final validBefore = BigInt.from(9223372036854775807); | |
final nonce = Nonce.secure(32); | |
final nonceBytes = utf8.encode(nonce.toString()); |