Intro to Smart Contract Development, Jan 2020
- Go through slides https://github.com/MetaMask/IPFS-Ethereum-Hackathon/blob/master/slides/01_DanFinlay_intro_to_ethereum_blockchains/DanFinlay-intro_to_ethereum.pdf
- deploy ballot to test net
- go over solidity language
- deploy ico to test net
- build webapp with truffle
- (stretch) deploy bonding curve token https://github.com/yosriady/continuous-token
Loading, Compiling, and not yet Deploying
Click the remix icon on the top of the icon panel to see the Landing Page.
In the Environments section, click the Solidity button.
In the icon panel, click file explorer icon.
Click ballot.sol & the file should appear in the main panel in a tab.
Click the solidity compiler icon solidity compiler icon.
Click the compile button compile ballot and watch it compile.
Deploying a contract
We've got a compiled contract.
Now we have to put that code on a simulation of a blockchain.
Click the Deploy and Run icon deploy & run icon. But before you click it, make sure that ballot.sol is the active tab.
In the text box to the right of the Deploy button, put a number in this text box.
Click the Deploy button.
You have deployed the contract to the JSVM.
Interacting with the functions in a deployed contract
Open up the contract by clicking the caret - so the caret points down.
There are 4 functions in this contract.
If this contract had imported other contracts then the functions of the imported contracts would be visible here too.
Blue buttoned functions are either pure or view functions.
Ballot.sol does not have a payable function. If it did the button's color would be red.
Deploying to a test net.
Click the MetaMask icon in your browser. Sign in and choose the rinkeby test network.
Go back to Remix. In the deploy plugin, in the Environment pulldown, choose Injected Web3.
Deploy your compiled ballot.sol.
You'll see the MetaMask popup asking you to pay for the transactions.
Your transaction will be broadcasted to the test blockchain and included in the next mined block. Study the generated etherscan link.
Go through slides
deploy ico to test net
- copy https://github.com/bitfwdcommunity/ICO-tutorial/blob/master/ico-contract.sol into remix
- Go to Line 3–15 and look at the comment section. Although this is a comment section, this will help you down the track. The name of the template ICO is ‘bitfwd’ CROWDSALE token contract
- Change Line 4 to the title of your crowdsale.
- You will just change Line 6 after you deploy the contract on the Blockchain.
- Change Line 7’s Symbol to your respective coin name (Keep it short)
- Change Line 8 to the name of your token
- Go to Line 102 and change “bitfwd” to “(YourCrowdsaleName). DON’T USE SPACE OR IT WON’T WORK.
- Do the same for Line 118
- Go to Line 119 and change the symbol name, the same as the ones you did in the comment section
- Do the same for Line 120
- Leave Decimals at 18.
- On line 122 you will have to define you first ICO parameter, when does the bonus end?
- And on line 123, you will define when does the Crowdsale ends.
- go to line 212. On that comment, write what is the amount of tokens you will be giving away for ETH.
- On line 218, define how much people will get within the BONUS.
- On line 220, define how much people will get without the BONUS (the same ratio that you put on line 212). The “msg.value” is the amount of ETH that someone sent. So taking my contract as example, for every 1 ETH, i would give 1000 FWD in return.
- Now Under Compile→Choose the Token you are creating →Details
- Navigate to the build and deploy tab → Press Deploy Contract
- Click on the transaction tx or access https://ropsten.etherscan.io to check if the contract went through.
- Register this contract. To do that: In the Overview Tab → Click on the Contract Address
- Go to the Contract Code Tab → Click Verify and Publish
- Nearly there… The following steps are really important. So pay attention. Basically what we are doing here is trying to guarantee that the code fits what you saying you are deploying and registering this on the network. FOREVER.
- Be sure that the contract address field corresponds to the contract address that you have just deployed. Remember contract address is different to the MEW address you created so make sure not to get them confused
- The contract name has to match the one in the code, in my case is this: bitfwdToken. This was on Line 102 in your code
- To check which version of the complier, go back to the remix page where you got the BYTECODE from and look at the URL, the complier version will be there. In most cases it should be: v0.4.19+commit.c4cbbb05.js
- On Optimisation, choose No (We haven’t enable it before).
- On ENTER THE SOLIDITY CONTRACT CODE BELOW, copy the whole code from Remix, and paste in that area. NOT THE BYTECODE, but the code itself. Can also be copied from your text editor.
- *Remember to add on line 6 the contract address that has been generated!
- Now, leave the other fields in blank and click on Verify and Publish.
If you see a success page with green checkmarks you deployed your ico!
- https://github.com/ethereum/web3.js/ - web3 api docs
- https://solidity.readthedocs.io - solidity docs
- https://gitter.im/ethereum/solidity - chatroom for discussing solidity code
- https://github.com/chronaeon/beigepaper/blob/master/beigepaper.pdf - ethereum beige paper, an easier to read verson of the ethereum white paper
- https://github.com/ScottWorks/ConsenSys-Academy-Notes - notes from student during consensys academy
- https://github.com/ethereum/wiki/wiki - ethereum techincal wiki, covers research topics and current problems being tackled
- https://github.com/ePaperthereum/wiki/wiki/White-Paper - ethereum white paper
- https://docs.openzeppelin.com/starter-kits/2.3/ - openzepplin starter kit (alternative to truffle suite)
- https://remix.ethereum.org - browserbased soldity ide, very popular in the community
- https://ethfiddle.com - like jsfiddle but for solidity, good for sharing code you're stuck on
- https://ethgasstation.info - online gas calculator for estimating your costs
- install https://brew.sh
- (any windows specific steps?)
For all students
- install nodejs https://nodejs.org/
- install an editor, I recommend https://code.visualstudio.com
- install the truffle suite
$ npm install -g truffle
- install ganache
- install the chrome browser
- install the metamask chrome extension
- get test tokens for the Ropsten network via the faucet https://blog.bankex.org/how-to-buy-ethereum-using-metamask-ccea0703daec