GithubHelp home page GithubHelp logo

nguyenhuugiatri / truffle-deploy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from axieinfinity/truffle-deploy

0.0 0.0 0.0 7 KB

Fine-grained Truffle deployment.

License: MIT License

JavaScript 100.00%

truffle-deploy's Introduction

truffle-deploy

MIT license npm version

Fine-grained Truffle deployment, with:

  • Automatic gas estimation.
  • Transaction retries.
  • No Migrations contract.

Installation

npm install --dev truffle-deploy

Usage

Writing a deployment is relatively similar to what you do with a Truffle migration. You can put your deployments in any directory you want, but preferably NOT migrations since that could cause confusions.

// contracts/Ownable.sol

pragma solidity ^0.4.24;


contract Ownable {
  address public owner;

  constructor() public {
    owner = msg.sender;
  }

  modifier onlyOwner() {
    require(msg.sender == owner);
    _;
  }

  function transferOwnership(address _newOwner) external onlyOwner {
    owner = _newOwner;
  }
}
// deployments/001_ownable.js

const assert = require('assert');

module.exports = async ({ accounts, artifacts, deployer, logger, network }) => {
  const Ownable = artifacts.require('Ownable.sol');

  logger.info(`Hey, I'm running on "${network}".`);

  const ownable = await deployer.deploy(Ownable);
  assert.equal(await ownable.owner(), accounts[0]);

  logger.info('Transferring ownership to another address...');
  await deployer.execute(ownable.transferOwnership, accounts[1]);
  assert.equal(await ownable.owner(), accounts[1]);
};

And then you can run the deployment with:

npx truffle-deploy deployments/001_ownable.js

Contributing

The project is in an early stage. Currently some basic functionalities are still lacking (e.g. custom transaction options), so feel free to chime in and create issues/PRs.

License

MIT licensed.

truffle-deploy's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.