How To Deploy Smart Contracts On Expanse Blockchain ?

in #blockchain7 years ago

expanse-featured.png

What’s Expanse ?

The Expanse platform now has a two-year history of consistent growth and stability. Starting out small, but with big ideas, the team is growing and other projects are now coming on board to help make the dream a reality — limited only by the imagination and talent of all the diverse people around the world involved in the journey.

What’s the difference between Expanse and Ethereum?

Expanse has lower transactions fees and Expanse.tech has created a $1,000,000 development fund to provide financial grants to innovative projects built in and around Expanse. Awards range from $5,000 to $50,000, and there are no strings attached: you continue to own your IP, are free to publish however you wish, and can use the grant funds without any restrictions or obligations to Expanse except all projects must use the Expanse network in some way.

What is needed to setup an Expanse Smart Contract?

You need to have Gexp (go-expanse) installed and any web browser.

  • Download latest Gexp release
  • Building gexp requires Go and C compilers to be installed:
sudo apt-get install -y build-essential golang
  • Finally, build the gexp program using the following command.
  • And run it!
cd go-expanse-master
make gexp

gexp --rpc --rpccorsdomain "https://remix.ethereum.org/" console

This command allows remix connect to your node (We’ll talk about remix later).
Output should look like this:

Welcome to the Gexp JavaScript console!
instance: Gexp/v1.7.2-stable/linux-amd64/go1.9.2
coinbase: <your_address>
at block: 1173495 (Tue, 22 May 2018 20:35:48 EEST)
 datadir: /home/<your_user>/.expanse
 modules: admin:1.0 debug:1.0 eth:1.0 exp:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0
>

Your coinbase must have some Exp. If you want to deploy contract on Testnet (recommended for testing), make sure you run test network and mine some Exp on it. You can connect to testnetwork with command:

gexp --testnet --fast --cache=512 console

If this is your first time starting Gexp or you haven’t started it in a while, it may take a while for the blockchain to sync. You can check syncing progress with eth.syncing. If syncing is complete, this will return false, otherwise you must wait until currentBlock matches highestBlock. Usually gexp will full sync in less them hour.

Write Your First Smart Contract

Here is our smart contract token example. It is a simple token(not a ERC20 token) with just a constructor,two functions and some field. Copy this code to a plain text file ans save it.

pragma solidity ^0.4.21;
contract Coin { 
   // The keyword “public” makes those variables 
   // readable from outside. 
   address public owner; 
   string public name; 
   uint256 public totalSupply; 
   mapping (address => uint) public balances;               
   event Sent(address from, address to, uint amount);
 
   // contructor run only when the contract is created.
   function Coin() public { 
      totalSupply = 10000; 
      name = ‘dincCoin’; 
      owner = msg.sender; 
      balances[owner] = totalSupply; 
   } 
   function send(address receiver, uint amount) public { 
      if (balances[msg.sender] < amount) return;
      balances[msg.sender] -= amount; 
      balances[receiver] += amount; 
      emit Sent(msg.sender, receiver, amount); 
   }
}

Compile and Deploy Your Contract with Remix

Now we need to compile our solidity code into an interface (abi) and bytecode (bin) that can be deployed onto the blockchain.

1. Open remix and paste your code.
remix.png
2. Unlock your account.

personal.unlockAccount('0xD5a1a07d033169CFedA8AB7482D7006C5ea5e72A', "ltybc2012")

4. Open ‘run’ tab and change Envirenment from default “Injected Web3” to “Web3 Provider” and click ‘OK’.
This will create a connection between remix and your local node.

5. Set up Expanse Web3 Provider Endpoint — ‘http://localhost:9656' and click ‘OK’
screen3.png
6. Choose address with some Exp and click Deploy, it will create a new transaction, so wait until it will be mined.
screen4.png

Remix will be asked to save ABI before launch, so do it!
In your Gexp console you will see something like this:

> INFO [05-22|22:21:56] Submitted contract creation              fullhash=0x11179f830360611c86e007dce2ae40b635228e5bfb3b397d6651abf1e5bfbe7c contract=0xE6C6ad0dCCf94D18e9D47d47961e3852cc296973

And that’s it, now you can interact with your smart contract.

Interact with your contract

Wait about a minute for your contract to be mined on the Expanse network, then type you can call some functions or even send this tokens to another address.
screen6.png

Good Job

Congrats! You’ve successfully deployed your first smart contract onto the Expanse network, a fundamental step in the world of Expanse blockchain development.

Now you can deep dive into solidity docs and learn about ERC20 standart to release your token or even ICO. Also there are tools that speed this process up quite a bit. I personally use Truffle to deploy most of my contracts (they refer to the deployment process as “migrations”), and once they’re deployed I add them to the Expanse wallet to interact with them. You could even deploy contracts directly from Mist, or write a Python script to do the heavy lifting for you. As you can see there are plenty of ways to deploy and interact with smart contracts, it just takes some experimentation to figure out which method works best for your workflow.

Hope you enjoyed the writeup, post a comment below if you have any questions.

Connect

Discord
Telegram
RusTelegram

Learn more about Expanse — https://www.expanse.tech/

Exp.Grants

Sort:  

Congratulations @dinc! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You made more than 50 upvotes. Your next target is to reach 100 upvotes.

Click here to view your Board
If you no longer want to receive notifications, reply to this comment with the word STOP

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @dinc! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

Click here to view your Board

Do not miss the last post from @steemitboard:

Carnival Challenge - Collect badge and win 5 STEEM

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @dinc! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 3 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Coin Marketplace

STEEM 0.21
TRX 0.25
JST 0.038
BTC 98069.15
ETH 3438.73
USDT 1.00
SBD 3.11