Skip to content

estimateContract

Estimation for a speicifed contract transaction. The request can be used as the parameter to sendPinkCommand.

Usage

example.ts
import * as fs from 'node:fs'
import { estimateContract } from '@phala/sdk'
import { client, provider } from './setup'
 
const abi = fs.readFileSync('path/to/abi.json', 'utf-8')
const contractId = '0x...'
 
const contractKey = await client.getContractKeyOrFail(contractId)
const result = await estimateContract(client, {
    address: contractId,
    contractKey,
    abi,
    provider,
    functionName: 'setRemark',
    args: ['Hi Remark'],
})

Parameters

client

OnChainRegistry

The OnChainRegistry instance.

options

EstimateContractParameters

address

string | AccountId

contractKey

string

provider

AnyProvider

abi

Record<string, any> | Abi

functionName

string

args (optional)

any[]

deposit (optional)

number | bigint

transfer (optional)

number | bigint

Returns

Promise<EstimateContractResult>

The estimation result.

debugMessage

string

gasConsumed

Weight

gasRequired

Weight

storageDeposit

StorageDeposit

result

ContractExecResultResult

request

SendPinkCommandParameters