Need help with openzeppelin-test-helpers?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

268 Stars 86 Forks MIT License 253 Commits 27 Opened issues


Assertion library for Ethereum smart contract testing

Services available


Need anything else?

Contributors list

OpenZeppelin Test Helpers

Docs NPM Package Build Status

Assertion library for Ethereum smart contract testing. Make sure your contracts behave as expected.



npm install --save-dev @openzeppelin/test-helpers

Hardhat (formerly Buidler)


and the
npm install --save-dev @nomiclabs/hardhat-web3 web3

Remember to include the plugin in your configuration as explained in the installation instructions.



in your test files to access the different assertions and utilities.
const {
  BN,           // Big Number support
  constants,    // Common constants, like the zero address and largest integers
  expectEvent,  // Assertions for emitted events
  expectRevert, // Assertions for transactions that should fail
} = require('@openzeppelin/test-helpers');

const ERC20 = artifacts.require('ERC20');

contract('ERC20', function ([sender, receiver]) { beforeEach(async function () { // The bundled BN library is the same one web3 uses under the hood this.value = new BN(1);

this.erc20 = await;


it('reverts when transferring tokens to the zero address', async function () { // Conditions that trigger a require statement can be precisely tested await expectRevert( this.erc20.transfer(constants.ZERO_ADDRESS, this.value, { from: sender }), 'ERC20: transfer to the zero address', ); });

it('emits a Transfer event on successful transfers', async function () { const receipt = await this.erc20.transfer( receiver, this.value, { from: sender } );

// Event assertions can verify that the arguments are the expected ones
expectEvent(receipt, 'Transfer', {
  from: sender,
  to: receiver,
  value: this.value,


it('updates balances on successful transfers', async function () { this.erc20.transfer(receiver, this.value, { from: sender });

// BN assertions are automatically available via chai-bn (if using Chai)
expect(await this.erc20.balanceOf(receiver));

}); });

Learn More



We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.