Make a basic Hello Word Smart Contract
1. Installation of binaries
The command below will download the binaries for each operating system.
Installing Brew Mac OS X
wget https://vexanium.com/files/vex1.7.4bin_macos.zip
unzip vex1.7.4bin_macos.zip
Installing the Ubuntu 18.04 Debian Package
Wget https://vexanium.com/files/vex1.7.4bin_ubuntu18.zip
unzip vex1.7.4bin_ubuntu18.zip
Install VEX.CDT
Perform the following steps:
Sell:
wget https://vexgift.s3-ap-southeast-1.amazonaws.com/dl/vex.cdt.amd64.deb
sudo apt install ./vex.cdt.amd64.deb
Add a VEXCPP compiler
After you install vex.cdt install vexcpp:
Vexcpp is a compiler where we will later need to compile the contract code
Perform the following command
Sell:
wget https://vexgift.s3-ap-southeast-1.amazonaws.com/dl/vex.cdt.add.amd64.deb
sudo apt install ./vex.cdt.add.amd64.deb
2. Starting Keosd
First step start keosd do the following command:
Sell:
./keosd $
You will see several outputs that look like this:
Webinar How to Create a Smart Contract on the Vexanium6.3 Blockchain Make a Development wallet
Check the wallet to make sure in advance
Sell:
./cleos wallet list
It will look like this
[]
This indicates that there is no wallet yet
After you start Keosd and make sure your wallet can go to the next step to create a development wallet, complete the following steps:
Shell:
./cleos wallet create --to-console
It will look like this:
Save password to use in the future to unlock this wallet.
Without password imported keys will not be retrievable.
"PW5JW1X7QyYNGZsBBchsV3xr8Y5Xdqzspaso6vS33jHBN7mzyGKaa"
Save the password later will be used to access the development wallet, After that, check back the wallet with the following command
Sell:
./cleos wallet list
It will look like this:
Wallets:
[
"default *"
]
Indicates that you have successfully created a development wallet with the default name wallet,
note the sign * by default your wallet is not locked, after that do the next steps:
Open wallet
If you have made a devolution but don’t see the wallet it could be your wallet closed. You don’t need to worry, you just have to open it to look again. Perform the following command to open it:
./cleos wallet open
If you have done the above command, the next step is to re-check your wallet
Sell:
./cleos wallet list
It will look like this:
[
"default"
]
Notice the * sign doesn’t exist, this indicates your wallet has been locked.
Every time you open an wallet or wallet you don’t access it wallet will be locked.
4. Unlock wallet and Import Key
After you create a development wallet the next step is to import keys, you can use your own key. Check wallet, make sure whether the wallet is unlocked or locked, if the wallet is locked do unlock the wallet first but if the wallet is unlocked skip the following steps
Example:
Sell:
./cleos wallet unlock --password PW5JW1X7QyYNGZsBBchsV3xr8Y5Xdqzspaso6vS33jHBN7mzyGKaa
Will be seen:
Unlocked: default
This indicates that your wallet has been unlocked,
Note: behind –password is your wallet password so change it using your password. After the wallet is unlocked the next step is to import the key.
Example
Perform the following commands:
./cleos wallet import --private-key
5Hudvm81HgTgz5UEQMED8Bpem1SmpCrYfVn4K1Qs2J4H2B5S9Vu
Later it will appear like this:
imported private key for: VEX64JnMok6LNudGtzcPyd3L7CJ5YB93Y76kv1AVizRzyyegK3S7Q
5Hudvm …… this is your private key
VEX64 …… this is the public key of the private key that you import
,
you can also save it.
Keep the two keys in several places, don’t lose them, because later you will need them.
5. Creating a Directory Contract
You need to choose the recommended directory to contract the directory on your local drive
mkdir CONTRACTS_DIR
6. Make a basic Hello Word Smart Contract
- Open the contract directory that you have created
cd CONTRACTS_DIR
- Make an example hello world directory song
mkdir hello
cd hello
After you create a directory for the contract, it’s time to go to the next stage to make an example
this contract with c ++ code is an example of a basic helloword contract. - Create a file named hello.cpp. for example
touch hello.cpp
after that edit the cpp file that you have made with your favorite editor and enter the following code into the cpp file that you have made.#include <eosio/eosio.hpp>
using namespace eosio;
class [[eosio::contract]] hello : public contract {
public:
using contract::contract;
[[eosio::action]]
void hi( name user ) {
print( "Hello, ", user);
}
};
the next step you can compile your code into web assembly (.wasm) as follows.
Shell:
Vexcpp hello.cpp -o hello.wasm
After that go back to the directory where there are cleos.
7. Buy ram and do a Set Contract (Publish Contract)
After you complete the steps above, it’s time to do a Publish Contract, but you must first ensure that the state of wallet development must be in an unlocked position if the wallet is locked. You need to unlock the wallet. save (accounts, assets, contracts, and other data). Note: The bigger your contract, the more RAM you need. The example below I will make a RAM purchase using 10 VEX examples:
Sell:
./cleos --url https://explorer.vexanium.com:6960 system buyram account_pengirim account_penerima "10 VEX"
After you think the ram is enough you can do the publish contract again.
Shell:
./cleos --url https://explorer.vexanium.com:6960 set contract account_anda CONTRACTS_DIR/hello
You can track all transactions you use https://explorer.vexanium.com/ including when you publish contracts.
8. Perform actions with smart contracts
After your contract is published it’s time to take action on the smart contract that you made earlier, Perform the following command to perform actions with the hello word smart contract that has been published.
Shell:
./cleos --url https://explorer.vexanium.com:6960 push action account_contractmu hi '["account"]' -
p account@active
You can also see your actions in Explorer Vexanium