Skip to main content
Last updated

pactjs cli

generate

Generate client based on a contract

ParameterDescriptionRequiredDefault value
-c, --cleanClean existing generated filesNo
-i, --caps-interfaceCustom name for the interface of the caps. Can be used to create a type definition with a limited set of capabilities.No
-f, --fileGenerate d.ts from Pact contract fileIf --contract is ommitted
--contractGenerate d.ts from Pact contract from the blockchainIf --file is ommitted
--apiThe API to use for retrieving the contract (e.g. https://api.chainweb.com/chainweb/0.0/mainnet01/chain/8/pact )When --contract is provided
--chainThe chainId to retrieve the contract fromWhen --contract is provided0
--networkThe networkId to retrieve the contract from (e.g. testnet)When --contract is providedmainnet

Generate from file

sh
pactjs contract-generate --file ./myContract.pact
sh
pactjs contract-generate --file ./myContract.pact

Generate from chain

sh
pactjs contract-generate --contract free.coin --api https://api.testnet.chainweb.com/chainweb/0.0/testnet04/chain/1/pact --chain 1 --network testnet
sh
pactjs contract-generate --contract free.coin --api https://api.testnet.chainweb.com/chainweb/0.0/testnet04/chain/1/pact --chain 1 --network testnet

retrieve-contract

Retrieve a contract from an API using a /local call

ParameterDescriptionRequiredDefault value
-m --moduleThe module you want to retrieve (e.g. "coin")Yes
-o, --outFile to write the contract to (e.g. ./myContract.pact)Yes
-a, --apiAPI to fetch the contract from (e.g. https://api.chainweb.com/chainweb/0.0/mainnet01/chain/8/pact )Yeshttps://api.chainweb.com
-n, --networkNetwork to retrieve from (e.g. testnet)Nomainnet

Retrieve a contract from chain

sh
pactjs retrieve-contract --out ./myContract.pact --module coin --api https://api.chainweb.com/chainweb/0.0/mainnet01/chain/8/pact
sh
pactjs retrieve-contract --out ./myContract.pact --module coin --api https://api.chainweb.com/chainweb/0.0/mainnet01/chain/8/pact

template-generate

Generate statically typed generators for templates

ParameterDescriptionRequiredDefault value
-c, cleanClean existing templateNo
-f, --fileFile or directory to use to generate the clientYes
-o, --outOutput file/directory to place the generated clientYes

Generate a client from a template

sh
pactjs template-generate --file ./contractDir --out ./myContract.pact
sh
pactjs template-generate --file ./contractDir --out ./myContract.pact