Deploying the WAX Guestbook Contract Locally
Tags: tutorial, blockchain, wax, cpp
Published: 2023-07-27 03:12:01

## Introduction

In the last section, we covered writing a WAX Guestbook Contract where accounts will be able to sign the contract with a memo that will be stored on the blockchain. In this section, we will deploy this contract to our locally running blockchain to test it out.

## Deploying the Contract Locally

Let’s deploy out contract to a blockchain in order to test it. Since this is a simple, self-contained contract, we can deploy to locally to test it before even interacting with a testnet blockchain. This is extremely useful when you want to test your contracts, but not worry about dealing with WAXP and RAM costs.

In the previous sections of the tutorial, when we started our Docker instance, we also started `nodeos`. We will need `nodeos` running in order to deploy locally.

Let’s deploy the Smart Contract:

```jsx
cleos set contract guestbook123 ./guestbook/build/guestbook -p guestbook123@active
```

Here we’ve called the `cleos set contract` action on our CLI, with the following arguments:

- `guestbook123` - the smart contract’s account
- `./guestbook/build/guestbook` - the path that contains our contract’s wasm file
- `-p guestbook123@active` the active permission for our smart contract’s account

Example output:


![Success output](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v10k1zg7m57u01z0gsxp.png)



We have successfully deployed the contract to our locally running WAX blockchain node! Our node isn’t connected to any other nodes, so no one else will be able to access our Smart Contract, but we can still interact with it to make sure it works.

### Interacting with the Contract

Now that we have deployed our contract to our local environment, its time to test some of the functionality!

We will start by signing the guestbook:

```cpp
cleos push action guestbook123 sign '["guestbook123","hello there"]' -p guestbook123@active
```

This time, we are pushing an action to the blockchain using the `cleos push action` CLI command with the following arguments:

- `guestbook123` - the smart contract’s account
- `'["guestbook123","hello there"]'` - the payload that matches the ACTION signature we want to call.
- `-p guestbook123@active` the active permission for our smart contract’s account

Example output:

```cpp
executed transaction: 7933cbb485e2a329d0d98c60c61ceffd1b0d7a4f33f87456b5518dddfcf6657e  112 bytes  357 us
#  guestbook123 <= guestbook123::sign           {"nm":"guestbook123","memo":"hello there"}
warning: transaction executed locally, but may not be confirmed by the network yet         ]
```

Let’s view the table’s contents to see how it looks:

```cpp
cleos get table guestbook123 guestbook123 guestbook
```

- `guestbook123` is the contract account
- The second `guestbook123` is the “scope” of the table we are searching, this was set when we created the table in our contract
- `guestbook` is the name of the table we specified in our contract.

Here I tested calling the contract multiple times, each time a new entry is added to the table:


![Example table output](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/27ik1o3s67r5uy71zeuq.png)



## Thinking Big

While this contract only stores an account name and a memo, you can imagine how powerful this is for creating interactive experiences on the blockchain. In [Dark Emblem NFT](https://darkemblem.com), we use blockchain tables to store our on-chain currency, store which cards are staked to the contract, and we use them to power our Raids where gamers can group up to tackle bosses with their NFTs.

Tables and Actions are the cornerstone of amazing interactive blockchain experiences, so think big!

## Conclusion

In this section, we were able to deploy our Guestbook Smart Contract from the last section to our locally running blockchain, sign it, and then view the data.

In upcoming parts of this tutorial series, we are going to deploy that contract to the Testnet and interact with it via more common tools like Bloks.io.

Next post: [Deploying the WAX Guestbook Contract to the Testnet](https://dev.to/idmontie/deploying-the-wax-guestbook-contract-to-the-testnet-29lh)

## E-book

Get this entire WAX tutorial as an [e-book on Amazon](https://amzn.to/3ZjwaK7).

## Additional links

- Photo by [Kenny Eliason](https://unsplash.com/@neonbrand?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) on [Unsplash](https://unsplash.com/photos/2c9ffiPlD9Q?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText)