readContract
Call a read function on a contract
​
This function will return the result from a contract read
1
venlyConnect.api.readContract({
2
"secretType": "MATIC",
3
"walletAddress": "0x0000000000000000000000000000000000000000",
4
"contractAddress": "0xE80F3baA739c18fd4eBf97716529a4b85BE464Dd",
5
"functionName": "balanceOf",
6
"inputs": [
7
{
8
"type": "address",
9
"value": "0x427d0addaa77d8bb871dbea3458dea4b5198730c"
10
},
11
{
12
"type": "uint256",
13
"value": "202"
14
}
15
],
16
"outputs": [
17
{
18
"type": "uint256"
19
}
20
]
21
})
Copied!

Signature

1
venlyConnect.api.readContract(request: ContractReadRequest): Promise<ContractReadResult>)
Copied!

Returns

1
Promise<ContractReadResult>
Copied!

Parameters

​
contractReadRequest
True
The request containing the parameters necessary to do the contract read

Example

1
const signer = venlyConnect.createSigner();
2
​
3
venlyConnect.api.readContract({
4
"secretType": "MATIC",
5
"walletAddress": "0x0000000000000000000000000000000000000000",
6
"contractAddress": "0xE80F3baA739c18fd4eBf97716529a4b85BE464Dd",
7
"functionName": "balanceOf",
8
"inputs": [
9
{
10
"type": "address",
11
"value": "0x427d0addaa77d8bb871dbea3458dea4b5198730c"
12
},
13
{
14
"type": "uint256",
15
"value": "202"
16
}
17
],
18
"outputs": [
19
{
20
"type": "uint256"
21
}
22
]
23
}).then((contractReadResult) => {
24
if (contractReadResult.success) {
25
console.log(`The balance for this contract and token is ${contractReadResult.result.value}`);
26
} else {
27
console.warn(`Something went wrong while reading the contract`);
28
}
29
}).catch((reason) => {
30
console.log(error);
31
});
Copied!

Object Types

Last modified 21d ago