Akash CLI

This guide will walk you through deploying a simple “Hello World” Next.JS application onto the Akash Network via The Akash CLI. This guide is beginner-friendly and requires no previous knowledge of navigating the Akash CLI or Akash Network in general.

Before Getting Started

You must have Akash CLI installed and properly configured along with some AKTs in your wallet(0.5 AKT minimum for a single deployment plus a small amount for transaction fees).

Follow CLI Installation Guide to install the Akash CLI if necessary.

Check your Account Balance

Check your account has sufficient balance by running:

Terminal window
provider-services query bank balances --node $AKASH_NODE $AKASH_ACCOUNT_ADDRESS

You should see a response similar to:

balances:
- amount: "93000637"
denom: uakt
pagination:
next_key: null
total: "0"

If you don’t have a balance, please see the funding guide. Please note the balance indicated is denominated in uAKT (AKT x 10^-6), in the above example, the account has a balance of 93 AKT. We’re now setup to deploy.

Note: Your account must have a minimum balance of 0.5 AKT to create a deployment. This 0.5 AKT funds the escrow account associated with the deployment and is used to pay the provider for their services. It is recommended you have more than this minimum balance to pay for transaction fees. For more information on escrow accounts, see here

STEP 1:- Create your Configuration

Create a deployment configuration deploy.yaml to deploy the akashlytics/hello-akash-world:0.2.0 for hello-akash-world which is a simple Next.JS “Hello World” application.

You can use CURL command to download the SDL file:

curl -s https://raw.githubusercontent.com/maxmaxlabs/hello-akash-world/master/deploy.yml > deploy.yml

The SDL file is the configuration file specifying all the needed resources like cpu, ram, storage etc. Since, this is a simple “Hello World” application so the needed resources will be very less.

STEP 2:- Create your Deployment

To deploy the sdl file that we curled in the previous step, run following command:

provider-services tx deployment create deploy.yml --from $AKASH_KEY_NAME

You should see a response similar to:

{
"height":"140325",
"txhash":"2AF4A01B9C3DE12CC4094A95E9D0474875DFE24FD088BB443238AC06E36D98EA",
"codespace":"",
"code":0,
"data":"0A130A116372656174652D6465706C6F796D656E74",
"raw_log":"[{\"events\":[{\"type\":\"akash.v1\",\"attributes\":[{\"key\":\"module\",\"value\":\"deployment\"},{\"key\":\"action\",\"value\":\"deployment-created\"},{\"key\":\"version\",\"value\":\"2b86f778de8cc9df415490efa162c58e7a0c297fbac9cdb8d6c6600eda56f17e\"},{\"key\":\"owner\",\"value\":\"akash1vn06ycjjnvsvl639fet9lajjctuturrtx7fvuj\"},{\"key\":\"dseq\",\"value\":\"140324\"},{\"key\":\"module\",\"value\":\"market\"},{\"key\":\"action\",\"value\":\"order-created\"},{\"key\":\"owner\",\"value\":\"akash1vn06ycjjnvsvl639fet9lajjctuturrtx7fvuj\"},{\"key\":\"dseq\",\"value\":\"140324\"},{\"key\":\"gseq\",\"value\":\"1\"},{\"key\":\"oseq\",\"value\":\"1\"}]},{\"type\":\"message\",\"attributes\":[{\"key\":\"action\",\"value\":\"create-deployment\"},{\"key\":\"sender\",\"value\":\"akash1vn06ycjjnvsvl639fet9lajjctuturrtx7fvuj\"},{\"key\":\"sender\",\"value\":\"akash1vn06ycjjnvsvl639fet9lajjctuturrtx7fvuj\"}]},{\"type\":\"transfer\",\"attributes\":[{\"key\":\"recipient\",\"value\":\"akash17xpfvakm2amg962yls6f84z3kell8c5lazw8j8\"},{\"key\":\"sender\",\"value\":\"akash1vn06ycjjnvsvl639fet9lajjctuturrtx7fvuj\"},{\"key\":\"amount\",\"value\":\"5000uakt\"},{\"key\":\"recipient\",\"value\":\"akash14pphss726thpwws3yc458hggufynm9x77l4l2u\"},{\"key\":\"sender\",\"value\":\"akash1vn06ycjjnvsvl639fet9lajjctuturrtx7fvuj\"},{\"key\":\"amount\",\"value\":\"5000000uakt\"}]}]}]",
"logs":[
{
"msg_index":0,
"log":"",
"events":[
{
"type":"akash.v1",
"attributes":[
{
"key":"module",
"value":"deployment"
},
{
"key":"action",
"value":"deployment-created"
},
{
"key":"version",
"value":"2b86f778de8cc9df415490efa162c58e7a0c297fbac9cdb8d6c6600eda56f17e"
},
{
"key":"owner",
"value":"akash1vn06ycjjnvsvl639fet9lajjctuturrtx7fvuj"
},
{
"key":"dseq",
"value":"140324"
},
{
"key":"module",
"value":"market"
},
{
"key":"action",
"value":"order-created"
},
{
"key":"owner",
"value":"akash1vn06ycjjnvsvl639fet9lajjctuturrtx7fvuj"
},
{
"key":"dseq",
"value":"140324"
},
{
"key":"gseq",
"value":"1"
},
{
"key":"oseq",
"value":"1"
}
]
},
{
"type":"message",
"attributes":[
{
"key":"action",
"value":"create-deployment"
},
{
"key":"sender",
"value":"akash1vn06ycjjnvsvl639fet9lajjctuturrtx7fvuj"
},
{
"key":"sender",
"value":"akash1vn06ycjjnvsvl639fet9lajjctuturrtx7fvuj"
}
]
},
{
"type":"transfer",
"attributes":[
{
"key":"recipient",
"value":"akash17xpfvakm2amg962yls6f84z3kell8c5lazw8j8"
},
{
"key":"sender",
"value":"akash1vn06ycjjnvsvl639fet9lajjctuturrtx7fvuj"
},
{
"key":"amount",
"value":"5000uakt"
},
{
"key":"recipient",
"value":"akash14pphss726thpwws3yc458hggufynm9x77l4l2u"
},
{
"key":"sender",
"value":"akash1vn06ycjjnvsvl639fet9lajjctuturrtx7fvuj"
},
{
"key":"amount",
"value":"5000000uakt"
}
]
}
]
}
],
"info":"",
"gas_wanted":"100000",
"gas_used":"94653",
"tx":null,
"timestamp":""
}

Find your Deployment

Find the Deployment Sequence (DSEQ) in the deployment you just created. For example, in the current deployment the dseq value is 140324, which you can confirm in the response above.

Then run the following command, make sure to copy paste the DSEQ value from your deployment:

Terminal window
export AKASH_DSEQ=CHANGETHIS

Now set the Order Sequence (OSEQ) and Group Sequence (GSEQ). Note that if this is your first time deploying on Akash, OSEQ and GSEQ will be 1.

Terminal window
AKASH_OSEQ=1
AKASH_GSEQ=1

Verify we have the right values populated by running:

Terminal window
echo $AKASH_DSEQ $AKASH_OSEQ $AKASH_GSEQ

STEP 3:- View your Bids and choose a provider

After a short time, you should see bids from providers for this deployment with the following command:

Terminal window
provider-services query market bid list --owner=$AKASH_ACCOUNT_ADDRESS --node $AKASH_NODE --dseq $AKASH_DSEQ --state=open

Choose a Provider

Note that there are bids from multiple different providers. In this case, both providers happen to be willing to accept a price of 1 uAKT. This means that the lease can be created using 1 uAKT or 0.000001 AKT per block to execute the container. You should see a response similar to:

bids:
- bid:
bid_id:
dseq: "140324"
gseq: 1
oseq: 1
owner: akash1vn06ycjjnvsvl639fet9lajjctuturrtx7fvuj
provider: akash10cl5rm0cqnpj45knzakpa4cnvn5amzwp4lhcal
created_at: "140326"
price:
amount: "1"
denom: uakt
state: open
escrow_account:
balance:
amount: "50000000"
denom: uakt
id:
scope: bid
xid: akash1vn06ycjjnvsvl639fet9lajjctuturrtx7fvuj/140324/1/1/akash10cl5rm0cqnpj45knzakpa4cnvn5amzwp4lhcal
owner: akash10cl5rm0cqnpj45knzakpa4cnvn5amzwp4lhcal
settled_at: "140326"
state: open
transferred:
amount: "0"
denom: uakt
- bid:
bid_id:
dseq: "140324"
gseq: 1
oseq: 1
owner: akash1vn06ycjjnvsvl639fet9lajjctuturrtx7fvuj
provider: akash1f6gmtjpx4r8qda9nxjwq26fp5mcjyqmaq5m6j7
created_at: "140326"
price:
amount: "1"
denom: uakt
state: open
escrow_account:
balance:
amount: "50000000"
denom: uakt
id:
scope: bid
xid: akash1vn06ycjjnvsvl639fet9lajjctuturrtx7fvuj/140324/1/1/akash1f6gmtjpx4r8qda9nxjwq26fp5mcjyqmaq5m6j7
owner: akash1f6gmtjpx4r8qda9nxjwq26fp5mcjyqmaq5m6j7
settled_at: "140326"
state: open
transferred:
amount: "0"
denom: uakt

For this example, we will choose provider akash10cl5rm0cqnpj45knzakpa4cnvn5amzwp4lhcal. Run following command to set the provider shell variable:

AKASH_PROVIDER=akash10cl5rm0cqnpj45knzakpa4cnvn5amzwp4lhcal

Verify we have the right value populated by running:

echo $AKASH_PROVIDER

STEP 4:- Create and confirm a Lease

Create a lease for the bid from the chosen provider above by running this command:

provider-services tx market lease create --dseq $AKASH_DSEQ --provider $AKASH_PROVIDER --from $AKASH_KEY_NAME

Confirm the Lease

You can check the status of your lease by running:

provider-services query market lease list --owner $AKASH_ACCOUNT_ADDRESS --node $AKASH_NODE --dseq $AKASH_DSEQ

Note the bids will close automatically after 5 minutes, and you may get the response:

bid not open

If this happens, close your deployment and open a new deployment again. To close your deployment run this command:

provider-services tx deployment close --dseq $AKASH_DSEQ --owner $AKASH_ACCOUNT_ADDRESS --from $AKASH_KEY_NAME

If your lease was successful you should see a response that ends with:

state: active

Note: Please note that once the lease is created, the provider will begin debiting your deployment’s escrow account, even if you have not completed the deployment process by uploading the manifest in the following step.

Send the Manifest

Upload the manifest using the values from above step:

provider-services send-manifest deploy.yml --dseq $AKASH_DSEQ --provider $AKASH_PROVIDER --from $AKASH_KEY_NAME

Confirm the URL

Now that the manifest is uploaded, your image is deployed. You can retrieve the access details by running the following command:

provider-services lease-status --dseq $AKASH_DSEQ --from $AKASH_KEY_NAME --provider $AKASH_PROVIDER

You should see a response similar to:

{
"services": {
"web": {
"name": "web",
"available": 1,
"total": 1,
"uris": [
"rga3h05jetf9h3p6dbk62m19ck.ingress.ewr1p0.mainnet.akashian.io"
],
"observed_generation": 1,
"replicas": 1,
"updated_replicas": 1,
"ready_replicas": 1,
"available_replicas": 1
}
},
"forwarded_ports": {}
}

You can access the application by visiting the hostnames mapped to your deployment. Look for a URL/URI and copy it to your web browser.

Then you should be able to see the landing page of the “Hello World” Application”

HelloWorld

View your logs

You can view your application logs to debug issues or watch progress like so:

Terminal window
provider-services lease-logs \
--dseq "$AKASH_DSEQ" \
--provider "$AKASH_PROVIDER" \
--from "$AKASH_KEY_NAME"

STEP 5:- Close Deployment

Close the Deployment

Now, since we have learned how to deploy the ‘Hello World’ application, we will close the deployment in order to not waste any AKTs. After closing the deployment we will get the remaing balance left as a refund.

Run following command to close the deployment:

provider-services tx deployment close --from $AKASH_KEY_NAME

Conclusion

We deployed a simple “Hello World” Next.JS application within 5 minutes. The process of deploying any other applications is identical, just the sdl file needs to be changed accordingly with proper configuration and container image.

footer-logo-dark

© Akash Network 2024 The Akash Network Authors Documentation Distributed under CC BY 4.0

Open-source Apache 2.0 Licensed.

GitHub v0.20.0

Privacy