-
I am trying to build transaction, contract token transfer UNSIGNED. I would like to build the transaction for offline signing at a later time. I have successfully executed a token transfer with a wallet/signer, but am having issues signing a offline transaction built to transfer tokens. ` const signed = wallet.signTransaction(tx); Error: invalid arrayify value (argument="value", value={}, code=INVALID_ARGUMENT, version=bytes/5.6.0) Can someone point me out in right direct, or send a link to an example of creating a token transfer transaction and method of signing offline. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
My objective is to generate a token transfer of USDT unsigned. Required data such as nonce etc can be requested from the provider to generate transaction, and manually populate other fields. I would then like to send this transaction to be sent to my offline wallet service which will be used to sign the transaction. Send the signed transaction to be broadcast from another part of my application with provider access. Is my objective even possible? if so, is it possible with ethers or web3 |
Beta Was this translation helpful? Give feedback.
-
Your code should work, I am not able to spot error. But I'm including some minimal code which you can try: const iface = new ethers.utils.Interface(['function transfer(address sender, uint amount)'])
const contractWithoutProvider = new Contract(iface, AddressZero); // note that there is no signer or provider here
const unsignedTx = await contractWithoutProvider.populateTransaction.transfer(AddressZero, parseUnits(amountStr, 18));
// now you can add more stuff to this unsignedTx like nonce and gas prices
unsignedTx.gasLimit = 210000;
unsignedTx.nonce = await this.provider.getTransactionCount(wallet.address);
unsignedTx.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas;
unsignedTx.maxFeePerGas = feeData.maxFeePerGas;
// now broadcast this object to your offline wallet, there it can sign it
const serializedSignedTx = await walletWithoutProvider.signTransaction(unsignedTx)
// now broadcast this to the network
await provider.sendTransaction(serializedSignedTx) |
Beta Was this translation helpful? Give feedback.
Your code should work, I am not able to spot error. But I'm including some minimal code which you can try: