Wondering what’s next for npm?Check out our public roadmap! »

    @chainlink/contracts

    0.1.7 • Public • Published

    Chainlink logo


    npm GitHub license npm downloads

    ⚠️ Migration Notice

    This package stores all of chainlink's smart contracts, previously known as the evm/ directory. The previous package was called chainlink, now it is @chainlink/contracts.

    Installation

    # via Yarn
    $ yarn add @chainlink/contracts
    
    # via npm
    $ npm install @chainlink/contracts --save

    Directory Structure

    This package makes use of @chainlink/belt to output artifacts along with ethers.js and truffle contract abstractions from the smart contracts stored within src. The resulting structure of the package when published looks like:

    contracts
    ├── abi # abi output from src/
    │   ├── v0.4
    │   ├── v0.5
    │   ├── v0.6
    │   ├── v0.7
    │   └── v0.8
    ├── ethers # ethers contract abstractions codegenned from abis
    │   ├── v0.4
    │   ├── v0.5
    │   ├── v0.6
    │   ├── v0.7
    │   └── v0.8
    ├── src # the contracts themselves, in .sol form
    │   ├── v0.4
    │   ├── v0.5
    │   ├── v0.6
    │   ├── v0.7
    │   └── v0.8
    └── truffle  # truffle contract abstractions codegenned from abis
        ├── v0.4
        ├── v0.5
        ├── v0.6
        ├── v0.7
        └── v0.8

    Usage

    These smart contracts can be imported as a dependency in various ways described below.

    Solidity

    The solidity smart contracts themselves can simply be imported via the src directory of @chainlink/contracts. If you wanted to consume the v0.4.x version of our Oracle smart contract, you could do the following:

    import "@chainlink/contracts/src/v0.4/Chainlinked.sol";

    Artifacts

    JSON artifacts generated by sol-compiler are available under the abi directory. If you wanted to consume the v0.4.x version of our Oracle JSON artifact with Javascript, you could do the following:

    const OracleV4Json = require('@chainlink/contracts/abi/v0.4/Oracle.json')

    Ethers

    This library ships with ethers.js contract abstractions generated by typechain. To use these, make sure you have ethers.js installed as a dependency:

    # via Yarn
    $ yarn add ethers@^4.0.44
    
    # via npm
    $ npm install ethers@^4.0.44 --save

    If you wanted to consume the v0.4.x version of our Oracle with JavaScript, you could do the following:

    import { OracleFactory } from '@chainlink/contracts/ethers/v0.4/OracleFactory'

    This gives a fully typed (if using TypeScript) version of a ethers.js contract factory. See the ethers.js documentation on usage.

    Truffle

    This library ships with @truffle/contract abstractions of each of our smart contracts. To use these, make sure you have @truffle/contract as a dependency.

    # via Yarn
    $ yarn add @truffle/contract@^4.1.8
    
    # via npm
    $ npm install @truffle/contract@^4.1.8 --save

    If you wanted to consume the v0.4.x version of our Oracle with JavaScript, you could do the following:

    const { Oracle } = require('@chainlink/contracts/truffle/v0.4/Oracle')

    For usage, see the @truffle/contract documentation.

    For ease of use with testing, if the environment variable NODE_ENV is set, the imported truffle contract abstraction will automatically set its provider to web3.currentProvider, avoiding the need to perform a setProvider call before using it during your truffle tests.

    NODE_ENV=true yarn truffle test

    Development

    Note: Contracts in src/v0.7/dev are under active development and not yet stable. Please use them for testing and development only.

    # Clone Chainlink repository
    $ git clone https://github.com/smartcontractkit/chainlink.git
    
    # Continuing via Yarn
    $ yarn install
    $ yarn setup:contracts
    
    # Continuing via npm
    $ npm install
    $ npm run setup:contracts

    Testing

    After completing the above Development commands, run tests with:

    # From this directory, `evm-contracts` via Yarn
    $ yarn test
    
    # via npm
    $ npm run test
    
    # From project root
    $ yarn wsrun @chainlink/contracts test

    Contributing

    Contributions are welcome! Please refer to Chainlink's contributing guidelines for detailed contribution information.

    Thank you!

    License

    MIT

    Keywords

    none

    Install

    npm i @chainlink/contracts

    DownloadsWeekly Downloads

    11,811

    Version

    0.1.7

    License

    MIT

    Unpacked Size

    23.3 MB

    Total Files

    1445

    Last publish

    Collaborators

    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar