Skip to content

Using the Smart Contract CLI

Options Description
-V, --version output the version number
-h, --help display help for command
Commands Description
login [options] login to ledgerswarm smartcontract wallet
getContractList [options] list smart contract instances
getAvailableContracts [options] list smart contracts available for deployment
getContractDetails [options] list the details of the specified smart contract
callFunction [options] call a function of the specified smart contract
newContract [options] deploy a new instance of specified smart contract
getContractState [options] show current state for a smart contract instance
watchContract [options] show current state for a smart contract instance specified in a file
logout logout of ledgerswarm smart contract wallet
help [command] display help for command

Login and Logout

Users interact with smart contracts via the Smart Contract Wallet. The wallet contains the certificates and keys needed to interact with a Smart Contract Host which runs and maintins the smart contract state. The wallet can also interact with LedgerSwarm to execute transactions on behalf of a smart contract.

login

lscontract help login

Imag1

lscontract login -u username -p password -s wallet.server.io

Imag1

logout

lscontract help logout

Imag1

lscontract logout

Available Contracts

Available contracts are the templates that are loaded onto the smart contract hosts you are conntected to. These are the contracts you can deploy.

getAvailableContracts

lscontract help getAvailableContracts

Imag1

lscontract getAvailableContracts -d table

Imag1

getContractDetails

Each contract comprises a collection of json schemas and javascript functions. The json schemas describe the contract roles, the contraints of each roles, the input values required to initialise a new instance and the parameters required to call the contract functions. The contract functions are javascript functions that alter the contract state in some way.

lscontract help getContractDetails

Imag1

lscontract getContractDetails -n 'Payment Mandate v5' -c BEEBANK

Imag1

Deploy a New Contract Instance

newContract

Create a new instance of an available contract. This will prompt you for the starting (genesis) values for the contract and will ask you which participants are assigned to each of the contract roles.

lscontract help newContract

Imag1

lscontract newContract -c BEEBANK

Imag1

Interacting with Contracts

getContractList

This lists all the deployed instances of smart contracts that you are a party to.

lscontract help getContractList

Imag1

lscontract getContractList -d table

Imag1

callFunction

This will call a contract function on a deployed instance.

lscontract help callFunction

Imag1

lscontract callFunction

Imag1

getContractState

This will display the current state of a deployed contract instance.

lscontract help getContractState

Imag1

lscontract getContractState

Imag1