Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

instantiate

Instantiate a contract from an already-uploaded code hash. Returns the derived address and the broadcast receipt.

Signature

function instantiate(
  client: Client<Signer>,
  parameters: {
    sender: Address
    codeHash: Hex
    msg: Json
    salt: Uint8Array | string
    funds?: Funds
    admin?: Address
    gasLimit?: number
    typedData?: TypedDataParameter
  },
): Promise<[string, { hash: Uint8Array } & TxData]>

Example

import { createSignerClient, createTransport, testnet, PrivateKeySigner } from "@left-curve/sdk"
import type { Address } from "@left-curve/sdk"
 
const client = createSignerClient({
  chain: testnet,
  transport: createTransport(),
  signer: PrivateKeySigner.fromMnemonic(process.env.DANGO_MNEMONIC!),
})
const sender: Address = "0x1234567890abcdef1234567890abcdef12345678"
 
const [address, receipt] = await client.instantiate({
  sender,
  codeHash: "0xabc...123",
  msg: { initialValue: "0" },
  salt: "counter-v1",
})

Parameters

senderAddress. The deployer.

codeHashHex. SHA-256 hash of the Wasm code (already stored via storeCode).

msgJson. Init message (camelCase).

saltUint8Array | string. Deterministic salt; strings are UTF-8 encoded. The contract address is derived from (sender, codeHash, salt).

fundsFunds, optional. Coins to send into the new contract.

adminAddress, optional. Account allowed to migrate the contract.

gasLimitnumber, optional. Override simulation.

typedDataTypedDataParameter, optional. Override the EIP-712 message body schema.

Returns

[address, receipt] — the derived contract address (from computeAddress) and the broadcast receipt.

See also