Deploying your first contract
This tutorial will take you through the entire process of writing a contract and deploying it on a local instance of ORBS in just a few minutes.
1. Write a simple contract
Let's write a simple example that implements a counter. Create a file named counter.go
and type in the following content
Don't worry if you don't fully understand the code at this point.
2. Start Gamma server
We'll test our contract on Gamma server. Start it from terminal
3. Deploy the contract
To deploy the counter contract, run in terminal
If the deploy is successful, you'll see a response similar to this
4. Send a transaction to increment the counter
Write the transaction details in a JSON file named add-25.json
To increment the counter by 75, let's send this transaction 3 times from terminal
Note that the transaction will be signed by user1
, an example account found in orbs-test-keys.json
5. Read the counter value
Write the query details in a JSON file named get.json
This query will read the counter value from the contract's state. Send it from terminal
Note that transactions that change state require consensus by several nodes. Reading state with queries is a simpler action that doesn't require consensus.
6. Stop Gamma server
Since we're done testing, the server is no longer needed. Let's stop it from terminal
Last updated