Skip to content

PinkBlueprintPromise

The PinkBlueprintPromise class allows the developer to manage calls to the phalaPhatContracts.instantiateContract. After uploaded your code to the cluster, you can use PinkBlueprintPromise to instantiate the Phat Contract in the cluster.

Usage

import * as fs from 'node:fs'
import { PinkBlueprintPromise } from '@phala/sdk'
 
const meta = JSON.parse(fs.readFileSync('path/to/contract.json', 'utf-8'))
const blueprint = new PinkBlueprintPromise(client, meta, meta.source.hash)
const result = await blueprint.send.new({ provider }, 'arg0', 'arg1')
await result.waitFinalized()
const contract = result.contract

Methods

send.*

Instantiate the Phat Contract in the cluster with specified provider.

* means the constructor method name of the contract, it useful new or default for most cases. If your constructor method name like snake_case, you need to convert it to camelCase when calling with SDK.

The first parameter is the options, and we only need pass provider here. The rest of the parameters are the constructor method's arguments.

Parameters

  • options
    • provider: AnyProvider
  • [...rest]: any[]

Returns

Promise<PinkBlueprintSubmittableResult>

query.*

Estimate the gas fee & storage deposit fee for the contract instantiate.

* means the constructor method name of the contract, it useful new or default for most cases. If your constructor method name like snake_case, you need to convert it to camelCase when calling with SDK.

Usage

import * as fs from 'node:fs'
import { PinkBlueprintPromise } from '@phala/sdk'
 
const meta = JSON.parse(fs.readFileSync('path/to/contract.json', 'utf-8'))
const blueprint = new PinkBlueprintPromise(client, meta, meta.source.hash)
const cert = await provider.signCertificate()
const { gasConsumed, gasRequired, storageDeposit, debugMessage, result, salt } = await blueprint.query.new(provider.address, { cert }, 'arg0', 'arg1')

Parameters

  • options
    • cert: CertificateData
    • salt: string (optional)
    • transfer: number | bigint | BN (optional)
    • deposit: number | bigint | BN (optional)
  • [...rest]: any[]

Returns

Promise<PinkContractInstantiateResult>

The PinkContractInstantiateResult includes following properties:

  • gasConsumed: WeightV2
  • gasRequired: WeightV2
  • storageDeposit: StorageDeposit
  • debugMessage: Text
  • result: InstantiateReturnValue
  • salt: string

tx.*

Get the contract transaction extrinct.

* means the constructor method name of the contract, it useful new or default for most cases. If your constructor method name like snake_case, you need to convert it to camelCase when calling with SDK.

You need call .signAndSend or use the signAndSend helper to submit the transaction.

Parameters

  • options
    • gasLimit: number | bigint | BN
    • storageDepositLimit: number | bigint | BN (optional)
    • value: number | bigint | BN (optional)
    • deposit: number | bigint | BN (optional)
    • salt: string (optional)
  • [...rest]: any[]

Returns

SubmittableExtrinsic<PinkBlueprintSubmittableResult>

PinkBlueprintSubmittableResult

waitFinalized

Wait for the transaction finalized.

contractId

string

The contractId of deployed contract.

contract

PinkContractPromise

The PinkContractPromise instance of deployed contract.