1

I am using Safe Core SDK in my web app(Next.js) project to generate and deploy Safes on Polygon Testnet(Mumbai) by the users. I can see the functions provided by SDK to create, sign and execute transactions for Ether/Matic transfer but am not able to understand how to send ERC20 and ERC721 tokens. Can someone please guide how to do this?

1 Answer 1

6

To create a token transfer you need to execute the following code:

import { SafeTransactionDataPartial } from '@gnosis.pm/safe-core-sdk-types'

const transaction: SafeTransactionDataPartial = {
  to: '<TOKEN_CONTRACT_ADDRESS>',
  value: '0',
  data: '<DATA>'
}
const safeTransaction = await safeSdk.createTransaction(transaction)

where TOKEN_CONTRACT_ADDRESS is the address of the token contract and DATA is the encoding of the call to the transfer method: contractInstance.methods.transfer(toAddress, amount).encodeABI()

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.