Build & Deploy

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.

What does a Smart Contract build to?

When you build a smart contract, it will produce two files:

What is an ABI?

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.

What is WebAssembly?

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.

Download source code

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 %}

Let's build!

Open the GlobalForce deploy web site

Click Add Files to build, updload file mycontract.cpp the one you downloaded earlier

Select entry file mycontract.cppfor 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.

Wallet connection processes

{% 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.

  1. Click fingerprint icon in the top-right corner or Connect Wallet.

  2. The wallet connection widget will appear with two options:

    • πŸ“± QR Code β€” to connect from another device.
    • πŸ’» Open App β€” to connect using a locally installed application.

    {% 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 β†’

    • πŸ“· Scan the QR code with your camera (if QR scanning is supported).
    • If not, log in wallet app, open the Wallet Connect menu wifi icon and select Scan QR Code for Connect.
  3. Start the connection using any method.

  4. πŸ” If you are not logged in yet then Log in to your account, or create/restore one.

⚠ If prompted to switch networks, confirm order.

  1. βœ… Complete the connection by accepting the Wallet Connect request.

{% note alert %}

Make sure that the application is active, otherwise the connection may be terminated.

{% endnote %}

Deploying to the testnet

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.

Interacting with the contract

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.

Congratulations!

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.

Build & Deploy

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

Loading...