Methods
The Clarinet JS SDK provides several methods that can be used to interact with simnet.
getAccounts
Retrieve a list of all Stacks addresses configured within the project, including wallets, deployers, and faucets.
Examples
Getting your accounts:
const accounts = simnet.getAccounts();
Response:
Map(10) {"wallet_7": "ST3PF13W7Z0RRM42A8VZRVFQ75SV1K26RXEP8YGKJ","wallet_1": "ST1SJ3DTE5DN7X54YDH5D64R3BCB6A2AG2ZQ8YPD5","wallet_3": "ST2JHG361ZXG51QTKY2NQCVBPPRRE2KZB1HR05NNC","wallet_5": "ST2REHHS5J3CERCRBEPMGH7921Q6PYKAADT7JP2VB","wallet_8": "ST3NBRSFKX28FQ2ZJ1MAKX58HKHSDGNV5N7R21XCP","wallet_4": "ST2NEB84ASENDXKYGJPQW86YXQCEFEX2ZQPG87ND","deployer": "ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM","wallet_6": "ST3AM1A56AK2C1XAFJ4115ZSV26EB49BVQ10MGCS0","wallet_2": "ST2CY5V39NHDPWSXMW9QDT3HC3GD6Q6XX4CFRK9AG","faucet": "STNHKEPYEPJ8ET55ZZ0M5A34J0R3N5FM2CMMMAZ6",}
Selecting a specific account:
const accounts = simnet.getAccounts();const wallet = accounts.get('wallet_1')!;
Response:
ST1SJ3DTE5DN7X54YDH5D64R3BCB6A2AG2ZQ8YPD5
Schema:
getAccounts(): Map<string, string>
getAssetsMap
Retrieve a list of asset balances associated with Stacks addresses, including fungible and non-fungible tokens.
Examples
Getting STX account balances:
const assets = simnet.getAssetsMap();const stxBalances = assets.get('STX')!;
Response:
Map(10) {"ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM": 100000000000000n,"ST1SJ3DTE5DN7X54YDH5D64R3BCB6A2AG2ZQ8YPD5": 100000000000000n,"ST2CY5V39NHDPWSXMW9QDT3HC3GD6Q6XX4CFRK9AG": 100000000000000n,"ST2JHG361ZXG51QTKY2NQCVBPPRRE2KZB1HR05NNC": 100000000000000n,"ST2NEB84ASENDXKYGJPQW86YXQCEFEX2ZQPG87ND": 100000000000000n,"ST2REHHS5J3CERCRBEPMGH7921Q6PYKAADT7JP2VB": 100000000000000n,"ST3AM1A56AK2C1XAFJ4115ZSV26EB49BVQ10MGCS0": 100000000000000n,"ST3NBRSFKX28FQ2ZJ1MAKX58HKHSDGNV5N7R21XCP": 100000000000000n,"ST3PF13W7Z0RRM42A8VZRVFQ75SV1K26RXEP8YGKJ": 100000000000000n,"STNHKEPYEPJ8ET55ZZ0M5A34J0R3N5FM2CMMMAZ6": 100000000000000n,}
Getting ft balances:
const contractName = 'token';const sourceCode = `(define-fungible-token sbtc)(ft-mint? sbtc u19 tx-sender)`;simnet.deployContract(contractName,sourceCode,null,simnet.deployer);const assets = simnet.getAssetsMap();const tokenBalance = assets.get('.token.sbtc')!;
Response:
Map(1) {"ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM": 19n,}
Getting nft balances:
const contractName = 'nft';const sourceCode = `(define-non-fungible-token ticket uint)(nft-mint? ticket u42 tx-sender)`;simnet.deployContract(contractName,sourceCode,null,simnet.deployer);const assets = simnet.getAssetsMap();const nftBalance = assets.get('.nft.ticket')!;
Response:
Map(1) {"ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM": 1n,}
Filtering for an account:
const assets = simnet.getAssetsMap();const stxBalances = assets.get('STX')!;const deployerBalance = stxBalances.get('ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM')!;
Response:
100000000000000n
Schema:
getAssetsMap(): Map<string, Map<string, bigint>>
getDataVar
Get the value of a data-var
defined in a contract.
Parameters
The contract identifier of the contract.
Example: counter
The name of the data-var
for the contract.
Example: count
Examples
Getting the value of a data variable:
const currentCount = simnet.getDataVar('counter', 'count');
Source code:
(define-data-var count uint u0)(define-data-var contractOwner principal tx-sender)(var-set count (+ (var-get count) u1))(var-set contractOwner 'ST1SJ3DTE5DN7X54YDH5D64R3BCB6A2AG2ZQ8YPD5)
Response:
{type: 1,value: 1n}
Converting Clarity values:
import { cvToValue } from '@stacks/transactions';const contractOwner = simnet.getDataVar("counter", "contractOwner");const response = cvToValue(contractOwner);
Response:
ST1SJ3DTE5DN7X54YDH5D64R3BCB6A2AG2ZQ8YPD5
Schema:
getDataVar(contract: string, dataVar: string): ClarityValue
getMapEntry
Get the value of a map entry by its key. Note that this method will always return an optional value some
or none
, just like Clarity map-get?
.
Parameters
The contract identifier of the contract.
Example: pool
The name of the map within the contract.
Example: Participants
The key to access the value in the map.
Example: Cl.standardPrincipal('ST1SJ3DTE5DN7X54YDH5D64R3BCB6A2AG2ZQ8YPD5')
Examples
Getting the value of an entry:
import { Cl } from '@stacks/transactions';const accounts = simnet.getAccounts();const wallet = accounts.get('wallet_1')!;const hasParticipated = simnet.getMapEntry("pool","Participants",Cl.standardPrincipal(wallet));
Source code:
(define-map Participants principal bool)(map-set Participants 'ST1SJ3DTE5DN7X54YDH5D64R3BCB6A2AG2ZQ8YPD5 true)
Response:
{type: 10,value: {type: 3,},}
Converting Clarity values:
import { Cl, cvToValue } from '@stacks/transactions';const accounts = simnet.getAccounts();const wallet = accounts.get('wallet_1')!;const hasParticipated = simnet.getMapEntry("pool","Participants",Cl.standardPrincipal(wallet));const response = cvToValue(hasParticipated);
Response:
{type: "bool",value: true,}
Schema:
getMapEntry(contract: string,mapName: string,mapKey: ClarityValue): ClarityValue
callReadOnlyFn
Call read-only functions exposed by a contract.
This method returns an object with the result of the function call as a ClarityValue
. It takes function arguments in the form of Clarity values, which are available in the package @stacks/transactions
.
Parameters
The contract identifier of the contract.
Example: pool
The name of the read-only function within the contract.
Example: get-participant
The arguments to pass to the read-only function. If no arguments are needed, pass an empty array.
Example: [Cl.standardPrincipal('ST1SJ3DTE5DN7X54YDH5D64R3BCB6A2AG2ZQ8YPD5')]
The Stacks address of the sender.
Example: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
Examples
Making a function call:
import { Cl } from '@stacks/transactions';const accounts = simnet.getAccounts();const wallet = accounts.get('wallet_1')!;const getContributionAmount = simnet.callReadOnlyFn('pool','get-contribution-amount',[Cl.standardPrincipal(wallet)],wallet);const response = getContributionAmount.result
Source code:
(define-map Participants principal bool)(define-map ParticipantStatus principal { enrollmentBlock: uint, contributionAmount: uint })(define-read-only (get-participant (who principal))(map-get? ParticipantStatus who))(define-read-only (get-contribution-amount (who principal))(default-to u0 (get contributionAmount (get-participant who))))(define-read-only (is-active)(map-get? Participants tx-sender))(map-set Participants tx-sender true)(map-set ParticipantStatus tx-sender { enrollmentBlock: block-height, contributionAmount: u42000000 })
Response:
{type: 1,value: 420000000n,}
With no arguments:
import { Cl } from '@stacks/transactions';const accounts = simnet.getAccounts();const wallet = accounts.get('wallet_1')!;const isActive = simnet.callReadOnlyFn('pool','is-active',[],wallet);const response = isActive.result
Response:
{type: 10,value: {type: 3,},}
With an explicit contract address:
import { Cl } from '@stacks/transactions';const accounts = simnet.getAccounts();const wallet = accounts.get('deployer')!;const contractAddress = `${wallet}.pool`;const getParticipant = simnet.callReadOnlyFn(contractAddress,'get-participant',[Cl.standardPrincipal(wallet)],wallet);const response = getParticipant.result;
Response:
{type: 9,}
Converting Clarity values:
import { Cl, cvToValue } from '@stacks/transactions';const accounts = simnet.getAccounts();const wallet = accounts.get('deployer')!;const getContributionAmount = simnet.callReadOnlyFn('pool','get-contribution-amount',[Cl.standardPrincipal(wallet)],wallet);const response = cvToValue(getContributionAmount.result);
Response:
42000000n
Schema:
type ParsedTransactionResult = {result: ClarityValue;events: ClarityEvent[];}callReadOnlyFn(contract: string,method: string,args: ClarityValue[],sender: string): ParsedTransactionResult
callPublicFn
Call public functions exposed by a contract.
This method returns an object with the result of the function call as a ClarityValue
and the events fired during the function execution. It takes function arguments in the form of Clarity values, which are available in the package @stacks/transactions
.
This method will simulate a block being mined and increase the block height by one.
Parameters
The contract identifier of the contract.
Example: pool
The name of the public function within the contract.
Example: register-participant
The arguments to pass to the public function. If no arguments are needed, pass an empty array.
Example: [Cl.standardPrincipal('ST1SJ3DTE5DN7X54YDH5D64R3BCB6A2AG2ZQ8YPD5')]
The Stacks address of the sender.
Example: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
Examples
Broadcasting your transaction:
import { Cl } from '@stacks/transactions';const accounts = simnet.getAccounts();const wallet = accounts.get('deployer')!;const registerParticipant = simnet.callPublicFn('pool','register-participant',[Cl.standardPrincipal(wallet)],wallet);const response = registerParticipant.result;
Source code:
(define-map Participants principal bool)(define-map ParticipantStatus principal { enrollmentBlock: uint, contributionAmount: uint })(define-public (register-participant (who principal))(begin(map-set Participants who true)(map-set ParticipantStatus who { enrollmentBlock: block-height, contributionAmount: u0 })(print { message: "Registered", who: who, at: block-height })(ok true)))(map-set Participants tx-sender true)(map-set ParticipantStatus tx-sender { enrollmentBlock: block-height, contributionAmount: u42000000 })
Response:
{type: 7,value: {type: 3,},}
Converting Clarity values:
import { Cl, cvToValue } from '@stacks/transactions';const accounts = simnet.getAccounts();const wallet = accounts.get('deployer')!;const registerParticipant = simnet.callPublicFn('pool','register-participant',[Cl.standardPrincipal(wallet)],wallet);const response = cvToValue(registerParticipant.result);
Response:
{type: "bool",value: true,}
Filtering for contract events:
import { Cl, cvToValue, type ClarityValue } from '@stacks/transactions';const accounts = simnet.getAccounts();const wallet = accounts.get('deployer')!;const registerParticipant = simnet.callPublicFn('pool','register-participant',[Cl.standardPrincipal(wallet)],wallet);const eventValues = registerParticipant.events.map((event) =>cvToValue(event.data.value as ClarityValue));
Response:
[{at: {type: "uint",value: "2",},message: {type: "(string-ascii 10)",value: "Registered",},who: {type: "principal",value: "ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM",},}]
Schema:
type ParsedTransactionResult = {result: ClarityValue;events: ClarityEvent[];}callPublicFn(contract: string,method: string,args: ClarityValue[],sender: string): ParsedTransactionResult
callPrivateFn
Call private functions exposed by a contract.
This method returns an object with the result of the function call as a ClarityValue
and the events, if any, fired during the function execution. It takes function arguments in the form of Clarity values, which are available in the package @stacks/transactions
.
This method will simulate a block being mined and increase the block height by one.
Parameters
The contract identifier of the contract.
Example: pool
The name of the private function within the contract.
Example: reward-participant-points
The arguments to pass to the private function. If no arguments are needed, pass an empty array.
Example: [Cl.standardPrincipal('ST1SJ3DTE5DN7X54YDH5D64R3BCB6A2AG2ZQ8YPD5')]
The Stacks address of the sender.
Example: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
Examples
Broadcasting your transaction:
import { Cl } from '@stacks/transactions';const accounts = simnet.getAccounts();const wallet = accounts.get('deployer')!;const address1 = accounts.get("wallet_1")!const rewardParticipantPoints = simnet.callPrivateFn("pool","reward-participant-points",[Cl.standardPrincipal(address1)],wallet);const response = rewardParticipantPoints.result;
Source code:
(define-map Participants principal bool)(define-map ParticipantStatus principal { enrollmentBlock: uint, contributionAmount: uint })(define-map ParticipantPoints principal int)(define-public (register-participant (who principal))(begin(map-set Participants who true)(map-set ParticipantStatus who { enrollmentBlock: block-height, contributionAmount: u0 })(reward-participant-points who)(print { message: "Registered", who: who, at: block-height })(ok true)))(define-private (reward-participant-points (who principal))(map-insert ParticipantPoints who 100))(map-set Participants tx-sender true)(map-set ParticipantStatus tx-sender { enrollmentBlock: block-height, contributionAmount: u42000000 })(map-set ParticipantPoints tx-sender 1000)
Response:
{type: 3,}
Converting Clarity values:
import { Cl, cvToValue } from '@stacks/transactions';const accounts = simnet.getAccounts();const wallet = accounts.get('deployer')!;const address1 = accounts.get("wallet_1")!const rewardParticipantPoints = simnet.callPrivateFn("pool","reward-participant-points",[Cl.standardPrincipal(address1)],wallet);const response = cvToValue(registerParticipant.result);
Response:
{type: "bool",value: true,}
Schema:
type ParsedTransactionResult = {result: ClarityValue;events: ClarityEvent[];}callPrivateFn(contract: string,method: string,args: ClarityValue[],sender: string): ParsedTransactionResult
transferSTX
Transfer STX from one address to another. The amount transferred is in uSTX
.
This method will simulate a block being mined and increase the block height by one.
Parameters
The amount of uSTX
to transfer.
Example: 1000000
equals 1 STX
The Stacks address of the recipient.
Example: ST1SJ3DTE5DN7X54YDH5D64R3BCB6A2AG2ZQ8YPD5
The Stacks address of the sender.
Example: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
Examples
Transferring STX:
const accounts = simnet.getAccounts();const recipient = accounts.get('wallet_1')!;const transfer = simnet.transferSTX(42000000, // 42 STXrecipient,simnet.deployer);
Response:
{result: {type: 7,value: {type: 3,},},events: [{event: "stx_transfer_event",data: [{amount: "42000000",memo: "",recipient: "ST1SJ3DTE5DN7X54YDH5D64R3BCB6A2AG2ZQ8YPD5",sender: "ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM",},],}],}
Converting Clarity values:
import { cvToValue } from '@stacks/transactions';const accounts = simnet.getAccounts();const recipient = accounts.get('wallet_1')!;const transfer = simnet.transferSTX(42000000, // 42 STXrecipient,simnet.deployer);const response = cvToValue(transfer.result);
Response:
{type: "bool",value: true,}
Filtering for contract events:
const accounts = simnet.getAccounts();const recipient = accounts.get('wallet_1')!;const transfer = simnet.transferSTX(42000000, // 42 STXrecipient,simnet.deployer);const events = transfer.events.map((event) => event);
Response:
[{event: "stx_transfer_event",data: {amount: "42000000",memo: "",recipient: "ST1SJ3DTE5DN7X54YDH5D64R3BCB6A2AG2ZQ8YPD5",sender: "ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM",},}]
Schema:
type ParsedTransactionResult = {result: ClarityValue;events: ClarityEvent[];}transferSTX(amount: number | bigint,recipient: string,sender: string): ParsedTransactionResult
deployContract
Deploy a contract to simnet.
This method will simulate a block being mined and increase the block height by one.
Parameters
The name of the contract to be deployed.
Example: hello-world
The Clarity source code (or content) of the contract.
Example: (define-read-only (say-hi) (ok "Hello World"))
An object to specify options, such as the Clarity version.
Example: { clarityVersion: 2 }
| null
The Stacks address of the sender.
Example: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
Examples
Deploying your contract:
import { cvToValue } from '@stacks/transactions';const sourceCode = '(define-read-only (say-hi) (ok "Hello World"))';const contract = simnet.deployContract('hello-world',sourceCode,null,simnet.deployer);const response = cvToValue(contract.result);
Response:
true
Specifying a Clarity version:
import { cvToValue } from '@stacks/transactions';const sourceCode = '(define-read-only (say-hi) (ok "Hello World"))';const contract = simnet.deployContract('hello-world',sourceCode,{ clarityVersion: 2 },simnet.deployer);const response = cvToValue(contract.result);
Response:
true
Interacting with your contract:
import { cvToValue } from '@stacks/transactions';const sourceCode = '(define-read-only (say-hi) (ok "Hello World"))';simnet.deployContract('hello-world',sourceCode,null,simnet.deployer);const sayHi = simnet.callReadOnlyFn("hello-world", "say-hi", [], simnet.deployer);const response = sayHi.result
Response:
{type: "(string-ascii 11)",value: "Hello World",}
Schema:
type ParsedTransactionResult = {result: ClarityValue;events: ClarityEvent[];}deployContract(name: string,content: string,options: DeployContractOptions | null,sender: string): ParsedTransactionResult
mineBlock
The callPublicFn
, transferSTX
, and deployContract
methods all mine one block with only one transaction. It can also be useful to mine a block with multiple transactions.
This is what mineBlock
is for.
This method takes an array of transaction objects. The transactions can be built with the tx
helper exported by the SDK.
The tx
helper has three methods:
callPublicFn
transferSTX
deployContract
These methods have the same interface as simnet methods but instead of performing a transaction, they will build a transaction object that can be passed to the mineBlock
function.
In epochs from 3.0 on, the stacks chaintip is advanced separately from the burn chaintip. This means mineBlock
will only affect the stacks chaintip. If you'd like to also mine burn blocks, use the mineEmptyBurnBlock
function.
Parameters
An array of transactions to be included in the block.
Example: [tx.transferSTX(100, recipient, sender), ...]
Examples
Mining multiple transactions in a single block:
import { tx } from '@hirosystems/clarinet-sdk';import { Cl, cvToValue } from '@stacks/transactions';const accounts = simnet.getAccounts();const wallet = accounts.get("wallet_1")!;const block = simnet.mineBlock([tx.callPublicFn("counter", "increment", [], simnet.deployer),tx.callPublicFn("counter", "add", [Cl.uint(10)], simnet.deployer),tx.transferSTX(19000000, wallet, simnet.deployer),]);block.forEach((transaction) => {console.log(cvToValue(transaction.result));if (transaction.events.length > 0) console.log(transaction.events);});
Source code:
(define-data-var count uint u0)(define-public (increment)(begin(var-set count (+ (var-get count) u1))(ok (var-get count))))(define-public (add (amount uint))(begin(var-set count (+ (var-get count) amount))(ok (var-get count))))
Response:
{type: "uint",value: "1",}{type: "uint",value: "11",}{type: "bool",value: true,}[{event: "stx_transfer_event",data: {amount: "19000000",memo: "",recipient: "ST1SJ3DTE5DN7X54YDH5D64R3BCB6A2AG2ZQ8YPD5",sender: "ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM",},}]
Schema:
type ParsedTransactionResult = {result: ClarityValue;events: ClarityEvent[];}mineBlock(txs: Tx[]): ParsedTransactionResult[]
mineEmptyBlock
Mine one empty block and increase the block height by one.
Returns the new block height.
Examples
Mining an empty block:
simnet.mineEmptyBlock();const response = simnet.blockHeight;
Response:
2
Schema:
mineEmptyBlock(): number
mineEmptyBlocks
Mine multiple empty blocks to reach a certain block height.
Returns the new block height.
Parameters
The number of empty blocks to mine. This parameter is optional.
Example: 5
Examples
Mining multiple empty blocks:
simnet.mineEmptyBlocks(5);const response = simnet.blockHeight;
Response:
6
Mining an empty block without a count:
simnet.mineEmptyBlocks();const response = simnet.blockHeight;
Response:
2
Schema:
mineEmptyBlocks(count?: number): number
runSnippet
Execute arbitrary Clarity code directly, which allows you to test and interact with smart contract functions without deploying them.
Parameters
The Clarity code snippet to be executed.
Example: (define-read-only (get-balance) (ok stx-balance))
Examples
Executing arbitrary Clarity code:
import { Cl } from '@stacks/transactions';const codeSnippet = simnet.runSnippet('(stx-account tx-sender)');const response = Cl.prettyPrint(codeSnippet, 2);
Response:
{locked: u0,unlock-height: u0,unlocked: u100000000000000}
Running a snippet for a STX transfer:
import { cvToValue } from "@stacks/transactions";const accounts = simnet.getAccounts();const recipient = accounts.get("wallet_1")!;const codeSnippet = simnet.runSnippet(`(stx-transfer? u19000000 tx-sender '${recipient})`);const response = cvToValue(codeSnippet);
Response:
{type: "bool",value: true,}
Schema:
runSnippet(snippet: string): string | ClarityValue
getContractsInterfaces
Returns the interfaces of the project contracts as a Map of Contracts, with the keys being the contract addresses.
These interfaces contain information such as the available functions
, data-vars
, maps
, NFTs
, and FTs
defined in the contract.
Examples
Getting a specific contract interface:
const contractInterfaces = simnet.getContractsInterfaces();const response = contractInterfaces.get(`${simnet.deployer}.pool`);
Source code:
(define-map Participants principal bool)(define-map ParticipantStatus principal { enrollmentBlock: uint, contributionAmount: uint })(define-read-only (get-participant (who principal))(map-get? ParticipantStatus who))(define-read-only (is-active)(map-get? Participants tx-sender))
Response:
{functions: [{name: "get-participant",access: "read_only",args: [[Object ...]],outputs: [Object ...],}, {name: "is-active",access: "read_only",args: [],outputs: [Object ...],}],variables: [],maps: [{name: "ParticipantStatus",key: "principal",value: [Object ...],}, {name: "Participants",key: "principal",value: "bool",}],fungible_tokens: [],non_fungible_tokens: [],epoch: "Epoch25",clarity_version: "Clarity2",}
Filtering for contract functions:
const poolContract = contractInterfaces.get(`${simnet.deployer}.pool`);const response = poolContract?.functions;
Response:
[{name: "get-participant",access: "read_only",args: [[Object ...]],outputs: [Object ...],}, {name: "is-active",access: "read_only",args: [],outputs: [Object ...],}]
Schema:
getContractsInterfaces(): Map<string, ContractInterface>
getContractSource
Get the source code of a contract as a string.
Parameters
The identifier of the contract for which the source code is requested.
Example: pool
Examples
Getting the source code of a contract:
const contractSource = simnet.getContractSource('pool');
Source code:
(define-map Participants principal bool)(define-map ParticipantStatus principal { enrollmentBlock: uint, contributionAmount: uint })(define-read-only (get-participant (who principal))(map-get? ParticipantStatus who))(define-read-only (is-active)(map-get? Participants tx-sender))
Response:
(define-map Participants principal bool)(define-map ParticipantStatus principal { enrollmentBlock: uint, contributionAmount: uint })(define-read-only (get-participant (who principal))(map-get? ParticipantStatus who))(define-read-only (is-active)(map-get? Participants tx-sender))
Schema:
getContractSource(contract: string): string | undefined
getContractAST
Get the full AST (Abstract Syntax Tree) of a Clarity contract.
This method throws an error if it fails to get the AST or to encode it.
Parameters
The identifier of the contract for which the AST (Abstract Syntax Tree) is requested.
Example: pool
Examples
Getting the source code of a contract:
const contractAST = simnet.getContractAST('pool');
Response:
{contract_identifier: {issuer: [ 26, [109, 120, 222, 123, 6, 37, 223, 191, 193, 108, 58, 138, 87, 53, 246, 220,61, 195, 242, 206] ],name: "pool",},pre_expressions: [],expressions: [{expr: [Object ...],id: 1,span: [Object ...],pre_comments: [],end_line_comment: undefined,post_comments: [],},...],top_level_expression_sorting: [ 0, 1, 2, 3 ],referenced_traits: Map {},implemented_traits: [],wasm_module: undefined,}
Schema:
getContractAST(contractId: string): ContractAST