Deploying a new contract (fio.staking)
This document attempts to describe the important commands that must be included in a deployment bundle when a FIO smart contract developer is preparing to deliver changes for release to test net and main net. The document also attempts to provide examples of the commands that are frequently used in the deployment bundle for projects delivering new contracts to the FIO protocol.
in order to begin the process of rollout testing, the developer must first set up a development environment in a configuration that matches the present main net release.
The developer must pull from the GitHub, the main net versions of the following repositories.
FIO
FIO.contracts
the developer must use a branch of fio.devtools which they have used for development, this branch must be further modified for rollout testing.
First, build the above versions,
Then archive/save the fio.contracts repository to a working directory fio.contracts.mainnet.
New the developer must pull the development version of their delivery and build this and stage it for use in rollout testing.
First, pull your development version of contracts, build this. archive/save this to a working directory called fio.contracts.staking.
next rename the fio.contracts.mainnet directory to be fio.contracts.
now, start up your local dev environment.
Run any smoke tests necessary to verify that the local dev environment is up and running.
next the developer can discover, or perform the set of commands used to deploy their changes onto the main net blockchain..
the following sequence of commands is for example purposes, the commands necessary are different for any project being delivered and these commands must be discovered and verified by the smart contract developer who develops the changes for the project to be delivered.
The first set of commands necessary to upgrade the main net chain performs the adding of new contract actions, and adds their associated fees to the main net chain. please be sure to list out in your rollout guide the add action and create fee commands necessary for the rollout of your project to the main net FIO protocol.
Addaction and createfee
Add new actions for staking
../fio/build/bin/clio -u http://localhost:8889 push action eosio addaction '{"action":"stakefio","contract":"fio.staking","actor":"eosio"}' --permission eosio
../fio/build/bin/clio -u http://localhost:8889 push action eosio addaction '{"action":"unstakefio","contract":"fio.staking","actor":"eosio"}' --permission eosio
../fio/build/bin/clio -u http://localhost:8889 push action eosio addaction '{"action":"incgstake","contract":"fio.staking","actor":"eosio"}' --permission eosio
../fio/build/bin/clio -u http://localhost:8889 push action eosio addaction '{"action":"incgrewards","contract":"fio.staking","actor":"eosio"}' --permission eosio
../fio/build/bin/clio -u http://localhost:8889 push action eosio addaction '{"action":"recorddaily","contract":"fio.staking","actor":"eosio"}' --permission eosio
../fio/build/bin/clio -u http://localhost:8889 push action eosio addaction '{"action":"decgstake","contract":"fio.staking","actor":"eosio"}' --permission eosio
../fio/build/bin/clio -u http://localhost:8889 push action eosio addaction '{"action":"incacctstake","contract":"fio.staking","actor":"eosio"}' --permission eosio
../fio/build/bin/clio -u http://localhost:8889 push action eosio addaction '{"action":"decacctstake","contract":"fio.staking","actor":"eosio"}' --permission eosio
../fio/build/bin/clio -u http://localhost:8889 push action eosio addaction '{"action":"paystake","contract":"fio.treasury","actor":"eosio"}' --permission eosio
../fio/build/bin/clio -u http://localhost:8889 push action eosio addaction '{"action":"modgenlocked","contract":"eosio","actor":"eosio"}' --permission eosio
Create the new fees
../fio/build/bin/clio -u http://localhost:8879 push action -f fio.fee createfee '{"end_point":"stake_fio_tokens","type":"1","suf_amount":"3000000000"}' --permission fio.fee@active
../fio/build/bin/clio -u http://localhost:8879 push action -f fio.fee createfee '{"end_point":"unstake_fio_tokens","type":"1","suf_amount":"3000000000"}' --permission fio.fee@active
After adding your new actions and fees to the protocol, it is common to next deploy modified contracts to the main net chain. Be sure you understand all of the contracts impacted by your changes, and the order in which they must be deployed onto main net, specify the set of commands to be executed to deliver all contract modifications. you may need to create a new contract account before doing this and add your new contract to the main net protocol, your needs will be unique to your project.
Deploy contracts
Deploy the changes to the system contract to permit the new contract as a fio system contract. Note this deploys the changes to locks, and the changes to add the new fio.staking account as a new fio account.
../fio/build/bin/clio -u http://localhost:8889 set contract -j eosio /home/ubuntu/fio.contracts.staking/build/contracts/fio.system fio.system.wasm fio.system.abi --permission eosio@active
if adding a new contract you will need to add the new owning account of the contract, and deploy the new contract
Create new contract/account and deploy the contract
#create the new account
../fio/build/bin/clio -u http://localhost:8879 create account eosio fio.staking FIO7isxEua78KPVbGzKemH4nj2bWE52gqj8Hkac3tc7jKNvpfWzYS FIO7isxEua78KPVbGzKemH4nj2bWE52gqj8Hkac3tc7jKNvpfWzYS -p eosio@active
#set the account permissions
../fio/build/bin/clio -u http://localhost:8879 set account permission fio.staking active '{"threshold": 1,"keys": [{"key": "FIO7isxEua78KPVbGzKemH4nj2bWE52gqj8Hkac3tc7jKNvpfWzYS","weight": 1}],"accounts": [{"permission":{"actor":"fio.staking","permission":"eosio.code"},"weight":1}]}}' 4000000000 owner -p fio.staking@owner
#set the account to be privileged.
../fio/build/bin/clio -u http://localhost:8879 push action eosio setpriv '["fio.staking",1]' -p eosio@active
When making a new contract account you need to remove ram limits on the account
#remove RAM limits on the new account, this may be called by eosio, and fio.system only!
../fio/build/bin/clio -u http://localhost:8889 push action eosio setnolimits '{"account":"fio.staking"}' --permission eosio@active
#set the contract on the new account
../fio/build/bin/clio -u http://localhost:8889 set contract -j fio.staking /home/ubuntu/fio.contracts.staking/build/contracts/fio.staking fio.staking.wasm fio.staking.abi --permission fio.staking@active
After setting up the new contract account you might then deploy the rest of the affected contracts. your project needs will be unique and the lead developer must identify the order of these events that are necessary to deploy your project onto main net.
Set all other contracts
#now deploy the rest of the contracts affected by staking integration.
#eosio.msig - Local WASM:
../fio/build/bin/clio -u http://localhost:8889 set contract -j eosio.msig /home/ubuntu/fio.contracts.staking/build/contracts/eosio.msig eosio.msig.wasm eosio.msig.abi --permission eosio.msig@active
#fio.address - Local WASM:
../fio/build/bin/clio -u http://localhost:8889 set contract -j fio.address /home/ubuntu/fio.contracts.staking/build/contracts/fio.address fio.address.wasm fio.address.abi --permission fio.address@active
#fio.fee - Local WASM:
../fio/build/bin/clio -u http://localhost:8889 set contract -j fio.fee /home/ubuntu/fio.contracts.staking/build/contracts/fio.fee fio.fee.wasm fio.fee.abi --permission fio.fee@active
#fio.request.obt - Local WASM:
../fio/build/bin/clio -u http://localhost:8889 set contract -j fio.reqobt /home/ubuntu/fio.contracts.staking/build/contracts/fio.request.obt fio.request.obt.wasm fio.request.obt.abi --permission fio.reqobt@active
#fio.token - Local WASM:
../fio/build/bin/clio -u http://localhost:8889 set contract -j fio.token /home/ubuntu/fio.contracts.staking/build/contracts/fio.token fio.token.wasm fio.token.abi --permission fio.token@active
#fio.tpid - Local WASM:
../fio/build/bin/clio -u http://localhost:8889 set contract -j fio.tpid /home/ubuntu/fio.contracts.staking/build/contracts/fio.tpid fio.tpid.wasm fio.tpid.abi --permission fio.tpid@active
#fio.treasury - Local WASM:
../fio/build/bin/clio -u http://localhost:8889 set contract -j fio.treasury /home/ubuntu/fio.contracts.staking/build/contracts/fio.treasury fio.treasury.wasm fio.treasury.abi --permission fio.treasury@active