In the previous section we wrote a simple smart contract. In this section we will build and deploy it to the blockchain using the GlobalForce Web Deploy.
When you build a smart contract, it will produce two files:
mycontract.wasm
- This is the compiled WebAssembly code that will run on the blockchain.mycontract.abi
- This is the ABI file that describes the interface to your smart contract.ABI stands for Application Binary Interface. It is a file that describes the interface to your smart contract. It contains information about the functions that your smart contract exposes, and the parameters that they take.
It also contains information about the data structures that your smart contract uses, and how they are stored in the blockchain. For instance, what tables are available, and what fields are in those tables.
WebAssembly is a binary instruction format for a stack-based virtual machine. It is designed as a portable target for compilation of high-level languages like C/C++/Rust, enabling deployment on the web for client and server applications.
Go ahead and download the following code: Download code
This is the code that we reviewed earlier
{% note tip %}
New browser window opens after clicking on the link. Right-click in the window that opens and select (Save As). This action will save the file to your device.
{% endnote %}
Open the GlobalForce deploy web site
Click Add Files to build
, updload file mycontract.cpp
the one you downloaded earlier
Select entry file mycontract.cpp
for build from the list.
Click Build Contract
If the build succeeds, you will see the wasm and abi files.
If the build fails, you will see the error message, with the line number where the error occurred.
{% note alert %}
If you missed the setup section, go back to it, install and setup the recommended wallet.
{% endnote %}
Link to Setup section
Go ahead.
Click in the top-right corner or
Connect Wallet
.
The wallet connection widget will appear with two options:
{% note tip %}
A locally installed application is one installed on the same device youβll use to connect to the DApp via Wallet Connect.
{% endnote %}
If the app is installed locally β click Open App.
If itβs on another device β
Start the connection using any method.
π If you are not logged in yet then Log in to your account, or create/restore one.
β If prompted to switch networks, confirm order.
{% note alert %}
Make sure that the application is active, otherwise the connection may be terminated.
{% endnote %}
Now that we have a smart contract that builds without errors, we can deploy it to the blockchain.
Now you can click on the Deploy Contract
.
A transaction confirmation window will appear in the application. Confirm this.
{% note alert %}
If you encounter an error during the deployment process indicating that you do not have enough resources to execute the smart contract action, click on "Buy Resources" to learn how to purchase resources.
{% endnote %}
{% note alert %}
If there are not enough funds in your account when purchasing resources, click on the "Faucet" to receive some amount of them to your account & and try buy resources again
{% endnote %}
This will deploy your smart contract to the GlobalForce Testnet, and allow you to interact with it.
If there are any errors during the deployment process, you will see them in browser and application.
Now that we have deployed our smart contract to the blockchain, we can interact with it.
Open explorer for GlobalForce TestNet.
Click the search button in the upper-right corner.
Enter your account name. You will see a page with information about your account.
Go to the CONTRACT
tab, after Actions
.
As you can see, we will need to reconnect our wallet to interact with this contract. Do it as we described it above.
You can fill out the fields for the save
action and click the Submit Transaction
button to execute the action.
After that, you will need to confirm this transaction in the application.
You can also view the entries in the table. To do this, go to the Table
tab. You will see the changes in your table.
You've now built and deployed your first smart contract to the blockchain, and interacted with it.
It's time for you to start building your own smart contracts! These docs will lead you through ever step of the way, but your first step is learning about the Anatomy of a smart contract.
You might also want to study some of the Core Concepts of the blockchain.
You are also ready to move on to the next section to study local development.
In the previous section we wrote a simple smart contract. In this section we will build and deploy it to the blockchain using the GlobalForce Web Deploy. When y