fbpx
February 17, 2019

Testing dates in Solidity smart contracts – Part I

Dates are a bit weird in Solidity. Solidity does have some keywords for working with dates, like now, or 1 day, but it does not have a native date type. Instead, dates are represented as integers, using timestamps in seconds. In our Truffle tests, we need to be able to…

Read Story
February 16, 2019

More tricks for bn.js (Big Number) library in Truffle tests

In the last video of the smart contract testing series I showed you the basic usage of the Big Number library to deal with integers. But Big Number has many more trick up his sleeves :) In this video, I will show you all these tricks so that you feel…

Read Story
February 14, 2019

Testing integers in smart contract with Truffle and bn.js (Big Number)

In Solidity smart contract, you might have to deal with huge numbers, especially when doing financial transfers. Don't forget that we need to specify Ether transfers in Wei, a fundamental unit equals to 1 * 10 ^ -18 Ether, so very quickly even small financial values can lead to big…

Read Story
February 12, 2019

Isolate smart contract tests with Truffle clean room features

In Truffle tests, we have a mysterious contract() function: contract('my test', () => { if('it should ...', () => { }); }); It's Truffle replacement of Mocha describe() function, but with a twist: it defines a "clean room" and it's used to isolate tests. Very few Truffle users, but this…

Read Story
February 10, 2019

Understanding Truffle variable injection magic in test files

In Truffle, when you write tests, you can use 'artifacts' and 'web3' objects, without defining these names: const MyContract = artifacts.require('MyContract'); //artifacts was never defined before ! const web3 = new Web3('http://localhost:8545'); //same thing for Web3! How is it possible? this is not valid Javascript! Well, this is what Truffle…

Read Story
February 9, 2019

Basic testing workflow with Truffle – Part 2

In this video, we will go through the whole process of test-driven-development (TDD) for Solidity smart contracts: writing the tests in Truffle running the failing tests with truffle test fixing the test by implementing the missing parts of the Solidity smart contract running the tests again, this time it will…

Read Story
February 7, 2019

Basic testing workflow with Truffle – Part I

In this video, I will show you what is the basic workflow when you test Solidity smart contracts with the Truffle framework. We are going to learn: files / test folder organization how to import smart contract into tests how to implement the arrange / test / assert pattern in…

Read Story
February 2, 2019

Install Truffle 5.0

Before we can continue in our course on Solidity smart contract testing, we need to install Truffle 5.0, so that we can benefit from all the new fancy features like support for ES6 async / await in our test files. In this video I am going to show you how…

Read Story
January 29, 2019

DAO – Part V

We will finally finish our DAO smart contract! So far we can vote for investment proposals, but after the voting time is over we need to actually execute the investment proposal, by sending some ether to the recipient address of the proposal. We will also use for the first time…

Read Story
January 27, 2019

DAO – Part IV

In this video, we are going to allow investors of the DAO to: create investment proposals vote on each investment proposal We will manipulate Solidity mappings a lot, including nested mappings. We will also use a storage pointer, to be able to manipulate a struct instance more easily. Any investors…

Read Story

Never miss a minute

Get great content to your inbox every week. No spam.
[contact-form-7 id="6" title="Footer CTA Subscribe Form"]
Arrow-up