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.
Option | Description | Type | Required |
---|---|---|---|
--version | Displays the version number of the program. | boolean | No |
--help | Displays the help message. | boolean | No |
--programAddress | Specifies the address to which data will be sent. | string | Yes |
--op | Specifies the operation to be performed. | string | Yes |
--txInputs | Specify a JSON file containing any custom parameters. | string | No |
--keypairPath | Specifies the path to the keypair file. | string | No |
--secretKey | Specifies the secret key for wallet access. | string | No |
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
- python
- javascript
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
}'
import requests
import json
url = "http://lasr-sharks.versatus.io:9292"
headers = {
"Content-Type": "application/json"
}
data = {
"jsonrpc": "2.0",
"method": "lasr_getAccount",
"params": ["<YOUR_PROGRAM_ADDRESS>"],
"id": 1
}
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())
const url = "http://lasr-sharks.versatus.io:9292";
const headers = {
"Content-Type": "application/json"
};
const data = {
jsonrpc: "2.0",
method: "lasr_getAccount",
params: ["<YOUR_PROGRAM_ADDRESS>"],
id: 1
};
fetch(url, {
method: "POST",
headers: headers,
body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
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
}
Access the example list to discover all available examples provided by Versatus.