Transfer a fungible token
How to perform a fungible transfer. E.g transfer an ERC20 token from one wallet to another.
It is not possible to transfer value from a wallet without the approval of the user. Therefore to be able to transfer a token, we will need to do two things: i) create the transfer and ii) ask the user for his approval.
The object that can ask the user his approval is called a Signer, once we've created a Signer object we can use the Signer to perform the token transfer.

Function

1
//Creating the signer
2
venlyConnect.createSigner();
3
​
4
//Asking the signer to transfer a certain value to a certain destination.
5
signer.executeTokenTransfer({
6
walletId: '<WALLET_ID>',
7
to: '<BLOCKCHAIN ADDRESS>',
8
value: 3.1415,
9
tokenAddress: '<TOKEN_BLOCKCHAIN ADDRESS>',
10
secretType: '<BLOCKCHAIN>',
11
})
Copied!

Example

Address
Email
1
const venlyConnect = new VenlyConnect('YOUR_CLIENT_ID');
2
​
3
//Creating the signer
4
const signer = venlyConnect.createSigner();
5
​
6
//Asking the signer to transfer ERC20 token to a blockchain address.
7
signer.executeTokenTransfer({
8
walletId: '71dec640-4eb8-4321-adb8-b79461573fc4',
9
to: '0xf147cA0b981C0CD0955D1323DB9980F4B43e9FED',
10
value: 1010,
11
tokenAddress: '0x02f96ef85cad6639500ca1cc8356f0b5ca5bf1d2'
12
secretType: 'ETHEREUM',
13
})
Copied!
1
const venlyConnect = new VenlyConnect('YOUR_CLIENT_ID');
2
​
3
//Creating the signer
4
const signer = venlyConnect.createSigner();
5
​
6
//Asking the signer to transfer ERC20 tokens to an email address
7
signer.executeTokenTransfer({
8
walletId: '71dec640-4eb8-4321-adb8-b79461573fc4',
10
value: 1010,
11
tokenAddress: '0x02f96ef85cad6639500ca1cc8356f0b5ca5bf1d2'
12
secretType: 'ETHEREUM',
13
})
Copied!
πŸ§™ The destination of a token transfer is not limited to a blockchain address, we also support email addresses and Unstoppable domains.

Returns

1
{
2
result: {
3
transactionHash: "0xe18975940be795f178b2a0bc553a0d40e0ad6ceb72ee5f62ac53f0a816b4460f"
4
}
5
status: "SUCCESS"
6
}
Copied!

Function Reference

The function reference describes the different functions that are available in the Widget. For each function you can find the signature, it's parameters, and possible options documented.