Call contract view method
POST {{baseUrl}}/protocols/eth/call
Execute a known view method of a given Ethereum smart contract within the EVM (using the latest block data), without transmitting a transaction to the blockchain. Method names, arguments, and expected outputs can be defined in the request body and must match the deployed ones of the contract on-chain. Otherwise, calls will result in errors.
While the to
body property is required and represents the contract address to call, the from
body property is optional and is used to specify the caller's wallet, address, or both.
If the from
parameter is omitted, the contract will be executed from the nodes default address e.g.
address(0)Thus,
msg.sender` in smart contracts will have the default value.
If both wallet
and address
properties are provided in from
or to
, the API validates if the address
resolves to the sending wallet
.
http-client
POST https://api.tangany.com/custody/protocols/eth/call
{
"from": {
"wallet": "my-wallet"
},
"to": "0xc06E361F2FBD2ef75dfA2cb3536dC77A4cCFc44c",
"method": "balanceOf(wallet) returns (uint)",
"inputs": [
"my-wallet"
],
}
The inputs
body parameter is optional and can be omitted from the call.
http-client
POST https://api.tangany.com/custody/protocols/eth/call
{
"to": "0xc06E361F2FBD2ef75dfA2cb3536dC77A4cCFc44c",
"method": "totalSupply() returns (uint256)",
}
You can use native json types in inputs:
{
"to": "0xc06E361F2FBD2ef75dfA2cb3536dC77A4cCFc44c",
"method": "emitMixed(int256, uint256, bool, string, wallet)",
"inputs": [
-100,
295,
true,
"example call",
"my-wallet"
]
}
However, only numbers up to 253-1 can be passed as native types. For any big values, use a string e.g. "2500000000000"
.
Request Body
{"from"=>{"wallet"=>"{{wallet}}"}, "to"=>"0xc06E361F2FBD2ef75dfA2cb3536dC77A4cCFc44c", "method"=>"balanceOf(wallet) returns (uint)", "inputs"=>["my-wallet"]}
HEADERS
Key | Datatype | Required | Description |
---|---|---|---|
tangany-version | number | (Required) Default header that directs the request towards desired Tangany Custody Api version (e.g 2 directs to Tangany Custody APi v2). |
Supports only major versions. |
| tangany-network
| string | | (Optional header) Define an API-supported public Ethereum network or a custom external Ethereum RPC endpoint to operate in.
Accepts supported public network enums and custom Ethereum RPC URLs. Defaults to mainnet
when omitted from the call.
Supported public networks: mainnet
, goerli
, sepolia
, polygon
, mumbai
, bsc
, bsc-testnet
, gnosis
, and chiado
.
Examples for private Ethereum RPC: https://somenetwork.example.org:8540?mykey
.
External RPCs must be whitelisted by the Tangany support in order to be used in the API.
Example: sepolia
|
| Content-Type
| string | | |
| Accept
| string | | |
RESPONSES
status: OK
{"list":[]}