Read a contract

Endpoint that allows you to read contract functions.

🚧

This function is only available for EVM-based chains.

Request Endpoint: reference

This endpoint allows you to read contract functions. This function is only available for EVM-based chains.

POST /api/contracts/read
ParameterParam TypeDescriptionData TypeMandatory
secretTypeBodyOn which blockchain the contract existsString
contractAddressBodyThe contract address that you want to readString
functionNameBodyThe contract function that you want to callString
inputsBodyTArray of inputs needed to call the functionArray
inputs.typeBodyType of the input parameter (ex. uint256)String
inputs.valueBodyValue of the input parameter. This needs to be passed as a string valueObject
outputsBodyAn array of expected outputsArray
outputs.typeBodyType of outputString

Examples

1. Get balance of

This example will get the balance of a certain NFT for a specific wallet.

POST https://api-wallet.venly.io/api/contracts/read

Request Body:

{
    "secretType": "MATIC",
    "walletAddress": "0x0000000000000000000000000000000000000000",
    "contractAddress": "0xE80F3baA739c18fd4eBf97716529a4b85BE464Dd",
    "functionName": "balanceOf",
    "inputs": [
        {
            "type": "address",
            "value": "0x427d0addaa77d8bb871dbea3458dea4b5198730c"
        },
        {
            "type": "uint256",
            "value": "202"
        }
    ],
    "outputs": [
        {
            "type": "uint256"
        }
    ]
}

Response Body:

{
    "success": true,
    "result": [
        {
            "type": "uint256",
            "value": 1
        }
    ]
}

2. Get Mint Number

This example will get the mint number for a specific NFT.

POST https://api-wallet.venly.io/api/contracts/read

Request Body:

{
    "secretType": "MATIC",
    "walletAddress": "0x0000000000000000000000000000000000000000",
    "contractAddress": "0xf86013ac3a23d26efb3337b4d63de6e6ec2a9861",
    "functionName": "mintNumber",
    "inputs": [
        {
            "type": "uint256",
            "value": "51"
        }
    ],
    "outputs": [
        {
            "type": "uint256"
        }
    ]
}

Response Body:

{
    "success": true,
    "result": [
        {
            "type": "uint256",
            "value": 2
        }
    ]
}

3. Get Contract URI

This example will fetch the contract URI, which contains the metadata, for a specific contract.

POST https://api-wallet.venly.io/api/contracts/read

Request Body:

{
    "secretType": "MATIC",
    "walletAddress": "0x0000000000000000000000000000000000000000",
    "contractAddress": "0x8c53de6a889cf0a3151168c3e84263c982d09a2f",
    "functionName": "contractURI",
    "outputs": [
        {
            "type": "string"
        }
    ]
}

Response Body:

{
    "success": true,
    "result": [
        {
            "type": "string",
            "value": "https://metadata.arkane.network/api/apps/0ed3a778-4f11-4cdf-b3cc-45f3225a9065/contracts/76/metadata"
        }
    ]
}