Contract
Contract Class
Creating a Contract Instance
import { Contract, NetworkConfig } from "@colibri/core";
const network = NetworkConfig.TestNet();
// Create from existing contract ID
const contract = new Contract({
networkConfig: network,
contractConfig: {
contractId: "CABC..." as ContractId,
},
});
// Create from WASM buffer
const contractFromWasm = new Contract({
networkConfig: network,
contractConfig: {
wasm: wasmBuffer,
},
});
// Create from WASM hash
const contractFromHash = new Contract({
networkConfig: network,
contractConfig: {
wasmHash: "abc123...",
},
});
// Optionally provide a custom RPC server
import { Server } from "stellar-sdk/rpc";
const customRpc = new Server("https://custom-rpc.example.com");
const contractWithCustomRpc = new Contract({
networkConfig: network,
rpc: customRpc,
contractConfig: {
contractId: "CABC..." as ContractId,
},
});Contract Methods
Getters
getContractId()
getContractId()getSpec()
getSpec()getWasm()
getWasm()getWasmHash()
getWasmHash()getContractFootprint()
getContractFootprint()getContractCodeLedgerEntry()
getContractCodeLedgerEntry()getContractInstanceLedgerEntry()
getContractInstanceLedgerEntry()Invoking Contract Methods
invoke() - State-Changing Calls
invoke() - State-Changing Callsread() - Read-Only Calls
read() - Read-Only CallsinvokeRaw() - Low-Level Invocation
invokeRaw() - Low-Level InvocationreadRaw() - Low-Level Read
readRaw() - Low-Level ReadDeploying Contracts
uploadWasm()
uploadWasm()deploy()
deploy()Loading Contract Metadata
loadSpecFromWasm()
loadSpecFromWasm()loadSpecFromDeployedContract()
loadSpecFromDeployedContract()loadWasmHashFromContractInstance()
loadWasmHashFromContractInstance()Contract Types
ContractId
Validating Contract IDs
Using Pipelines Directly
PIPE_InvokeContract
PIPE_InvokeContractPIPE_ReadFromContract
PIPE_ReadFromContractErrors
Code
Class
Description
Next Steps
Last updated