Skip to content

Instantly share code, notes, and snippets.

@lingqingmeng
Last active July 5, 2018 08:10
Show Gist options
  • Save lingqingmeng/cb8d3e82037a4846366c0981e4a4a898 to your computer and use it in GitHub Desktop.
Save lingqingmeng/cb8d3e82037a4846366c0981e4a4a898 to your computer and use it in GitHub Desktop.
Solidity tips

How to do well in the Hackathon

Message lingqingmeng in Slack or on telegram https://t.me/lingqingmeng

Get code to work in pieces everything

  • Break down functionality in small modular chunks, this way you are able to know exactly where the bug arises. Verify the success case works (positive test)
  • Ask questions early and often. It takes 10x longer to google something than it takes to ask one of us the question in Slack and get the answer - or any other student can also answer.
  • Make sure your version is up to date. I would recommend 4.18 or 4.24 for Solidity.

Do not get versions confused!!!

  • I would recommend web3 1.0.0. Documentation is very different and they are not backwards compatible. web3 0.20 documentation, very different than web3 1.0.0 documentation
  • Recommend Solidity pragma 4.18 or 4.24.
  • This is my truffle version running on OSX
truffle version  
Truffle v4.1.11 (core: 4.1.11)  
Solidity v0.4.24 (solc-js)  
  • Async operations. Javascript both in client and server is asynchronous. There are 3 ways to do asyncSome documentation uses callbacks, promises and async/await.
  • Async await will take you the longest to get up and running, you will need version nodejs version 8.5 or 10, and you will need babel to use ES7 code in backend.

Use awesome tools

  1. Get Infura to deploy to mainnet node, if you want to do most of the coding in Sublime/Visual Studio instead of Remix, you will need Infura and Truffle hd Wallet. Infura and Truffle HD Wallet
  2. To minimize gas, favor view or pure functions over mutating global state. Functions that write to blockchain globally. The web3 api has a method to estimate gas used in any method web3.eth.estimateGas.
  3. Setting up your own Geth or Parity node is not recommended

Know the details

  • gas: also known as gas or gasLimit. This is the maximum amount of gas that can go into a transaction. (how much volume your car's fuel tank has)
  • gasPrice: also known as gasPrice. This is the price
  • Get comfortable converting between hex and numbers. Favor web3 provided methods over trying to reinvent the wheel. Good examples from official ethereum developers
  • Many different conventions in how you import in a Solidity from other solidity files, vs how you import a Solidity file in a Javascript file. Don't make assumptions and ask questions as early as possible in Slack on how to properly import.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment