Skip to main content

LASR CLI

The LASR CLI enables you to build, test, create, and interact with your deployed program on the LASR network.

Interact with Your Deployed Program via CLI

Versatus provides the CLI so you can execute commands and transactions that showcase the capabilities of your program. The CLI offers a straightforward method to test and validate that your program operates as intended within the LASR network environment.

To start interacting with your deployed program via the CLI, use the following command structure:

npx lasrctl call [params]

The npx lasrctl command supports various options to tailor your interaction with the program. The following table lists the available options and describes the expected response. Notice that some of the options are required to use the CLI.

OptionDescriptionTypeRequired
--versionDisplays the version number of the program.booleanNo
--helpDisplays the help message.booleanNo
--programAddressSpecifies the address to which data will be sent.stringYes
--opSpecifies the operation to be performed.stringYes
--txInputsSpecify a JSON file containing any custom parameters.stringNo
--keypairPathSpecifies the path to the keypair file.stringNo
--secretKeySpecifies the secret key for wallet access.stringNo

The code block below presents an example of how you can use the CLI. In this case, the CLI is interacting with a LASR version of the traditional Hello World example. In the example, the user is trying to use the hello operation, providing the name parameter, which, in the example below was defined as Joe.

npx lasrctl call --programAddress <YOUR_PROGRAM_ADDRESS_FROM_DEPLOY> --op hello --txInputs '{"name": "Joe"}'

Each program you deploy has its own program address. You can call LASR's API to check the current state of each program. For this, use the code below:

  curl -X POST http://lasr-sharks.versatus.io:9292 \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "lasr_getAccount",
"params": ["<YOUR_PROGRAM_ADDRESS>"],
"id": 1
}'

The Hello LASR program used as example above, will return a response JSON where, inside result.programAccountData, you can find the hello key with the value "Hello, Joe! The time is 1718036700009!":

{
"jsonrpc": "2.0",
"result": "{\"accountType\":{\"program\":\"0x9004458e3ca47f235a1acc9d9e82a8ffe0ace913\"},
\"programNamespace\":null,\"ownerAddress\":\"0xd0bb5781e34e6bc6c2625ade52d06d048f5b9aa4\",\"programs\":{},
\"nonce\":\"0x0000000000000000000000000000000000000000000000000000000000000002\",\"programAccountData\":
{\"hello\":\"Hello, Joe! The time is 1718036700009!\",\"imgUrl\":\"https://pbs.twimg.com/profile_images/
1765199894539583488/RUiZn7jT_400x400.jpg\",\"methods\":\"hello\",\"type\":\"hello-lasr\"},
\"programAccountMetadata\":{\"content_id\":\"bafyreieg63zhbhg7x2fk4ugj4ehry3q4xxs52bnzybxubggwolfbritbky\",
\"initializedSupply\":\"1\",\"name\":\"MY_FIRST_PROGRAM\",\"symbol\":\"HELLO_WORLD\",\"totalSupply\":\"1\"},
\"programAccountLinkedPrograms\":[]}",
"id": 1
}
info

Access the example list to discover all available examples provided by Versatus.