Call a contract
How to perform a contract call
A contract call is the equivalent to launching a blockchain transaction. We've already covered that we can't execute a transaction without the user's approval. Therefore to be able to call a contract we will need to do two things i) define the contract call 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 contract call.

Function

1
//Creating the signer
2
venlyConnect.createSigner();
3
​
4
//Asking the signer to transfer a certain value to a certain destination.
5
signer.executeContract({
6
secretType: '<BLOCKCHAIN>',
7
walletId: '<WALLET_ID>',
8
to: '<BLOCKCHAIN ADDRESS>',
9
value: 0,
10
functionName: '<CONTRACT_FUNCTION_NAME>',
11
inputs: [
12
{type: "address", value: "0x80cbb6c4342948e5be81987dce8251dbedd69138"},
13
{type: "uint256", value: "73680000"}
14
]
15
})
Copied!

Example

1
const signer = venlyConnect.createSigner();
2
​
3
signer.executeContract({
4
secretType: 'ETHEREUM',
5
walletId: '71dec640-4eb8-4321-adb8-b79461573fc4',
6
to: '0xf147cA0b981C0CD0955D1323DB9980F4B43e9FED',
7
value: 0,
8
functionName: 'transfer',
9
inputs: [
10
{type: "address", value: "0x80cbb6c4342948e5be81987dce8251dbedd69138"},
11
{type: "uint256", value: "73680000"}
12
]
13
})
Copied!

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.
Last modified 1mo ago