Skip to content

sendPinkCommand

Submit a contract transaction to the cluster.

Usage

example.ts
import * as fs from 'node:fs'
import { estimateContract, sendPinkCommand } 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 { request } = await estimateContract(client, {
    address: contractId,
    contractKey,
    abi,
    provider,
    functionName: 'setRemark',
    args: ['Hi Remark'],
})
await sendPinkCommand(client, request) 

Parameters

client

OnChainRegistry

The OnChainRegistry instance.

options

SendPinkCommandParameters

address

string | AccountId

contractKey

string

provider

AnyProvider

abi

Record<string, any> | Abi

functionName

string

args (optional)

any[]

deposit (optional)

number | bigint | BN

transfer (optional)

number | bigint | BN

gasLimit

number | bigint | BN

plain (optional)

boolean

By default, the contract transaction is visible on chain and encrypted. If plain is true, the transaction will be visible on chain and not encrypted.

nonce (optional)

string It's not the nonce for the on-chain transaction (since it will be auto-incremented), it's the nonce for the off-chain transaction and you can use it as the identify of the transaction to filtering the logs.

value (optional)

number | bigint | BN

storageDepositLimit (optional)

number | bigint | BN

deposit (optional)

number | bigint | BN

Returns

Promise<SubmittableResult>