transferCrypto
How to call the API from an app
const snapId = `npm:@hashgraph/hedera-wallet-snap`
const transferCryptoAPI = async () => {
const externalAccountParams = {
externalAccount: {
accountIdOrEvmAddress: '0.0.12345',
curve: 'ED25519'
}
}
const transfers = [
{
assetType: 'HBAR', // 'HBAR' | 'TOKEN' | 'NFT'
to: '0.0.4498148',
amount: 1,
assetId?, // You must pass in a Token ID or NFT Id for transferring tokens
from?, // This can be passed if you're trying to do a delegated transfer
}
]
// If you're sending to an exchange account,
// you will likely need to fill this out
const memo = ''
await window.ethereum.request({
method: 'wallet_invokeSnap',
params: {
snapId,
request: {
method: 'transferCrypto',
params: {
network: 'testnet',
transfers,
memo,
maxFee: undefined
/*
Uncomment the below line if you want to connect
to a non-metamask account
*/
// ...externalAccountParams
}
}
}
})
}What the API does

Live Demo on CodePen
Last updated
Was this helpful?

