1.1.0 • Published 2 days ago

@chainlink/contracts v1.1.0

Weekly downloads
11,552
License
MIT
Repository
-
Last release
2 days ago

@chainlink/contracts

Chainlink's solidity contracts and contract abstractions

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.

Layout

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 layout of the package when published looks like:

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

Usage

Install this package with the following command:

yarn add @chainlink/contracts

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:

yarn add ethers@^4.0.44

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 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.

yarn add @truffle/contract@^4.1.8

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

Setup

After cloning the chainlink repo, run yarn install and then yarn setup:contracts.

Testing

After walking through the above setup commands, you can run yarn test from within evm-contracts/ or run yarn wsrun @chainlink/contracts test from the root.

@sirenprotocol/contractsdefi-warrior-core@jbox/contracts@htsoft/lottery-math-utils@3web/contracts@gm2/blockchaingeoracle@infinitebrahmanuniverse/nolb-_chai@georacle/contractsscw-contracts@everything-registry/sub-chunk-164@oyunprotocol/casino-contractshelix-bridge-corehashland-corehardhat-chainlink-pluginleparfumelayer3-coreeeseewen-protocol-v5ensurofmj-contractseesee-contractsfallback-gastankethst_v3gasx-coregast-coregas-savergaso-corefuntopia-coreerc721psipaddy-corepaddy-core-temppaddy-core-tmppavepo-smart-accountnum_complex_soliditynft-makerpolysnth-protocolmistransfersavmswapsealemlab-coresacredrealm-coreshiro-store@dirtycajunrice/contractsboc-contract-coreboc-protocol-coreboc-protocol-core-testtento-index@devilswheel/devils-wheel-abi@defi-warrior/core@defi-warrior/farm@dcpmm/core@decentology/hyperverse-ethereum-randompick@dev-extralabs/web3@defaino/contracts@divergencetech/ethier@dsla-protocol/contracts@dsla-protocol/coretoken_distributiontoken_with_distributiontoken-sale-contractstracer-pool-swapsstaking-contractsstarcraft-coreson123-trava-station-sdk-helloson123-trava-station-sdk-hello2testpackage-praveen5-othenavisapp@dao-hub/contracts-v1@dany-armstrong/hardhat-compoundsupervault@pendle/core-v2@perp/curie-contract@murphy-labs/strateg-protocol-borrow@predy/v2-contracts@pooltogether/tokenomics-testnet@pooltogether/v4-mainnet@pooltogether/v4-testnet@poolparty/token-vaults@phala/solidity@proofi/solidity@exodiafi/exodia-sdk@equilibria/perennial@equilibria/perennial-oracle@equilibria/perennial-v2@relative-finance/contracts@richeroneren/fast-presale@ragetrade/core@ragetrade/delta-neutral-gmx-jit@ribbon-finance/rvol@sakuracasino/roulette-contract@sc1/contractsvesting-contractscygnus-contractsusm-oraclesdatum-contracts@minterest/minterest-contracts@mimic-fi/v1-price-oracle@mimic-fi/v2-price-oracle@mimic-fi/v3-price-oracle@mimic-fi/v1-chainlink-price-oracle
1.1.1-beta.0

2 days ago

1.1.0

8 days ago

1.1.0-beta.0

26 days ago

1.0.0

1 month ago

1.0.0-beta.1

1 month ago

1.0.0-beta.0

4 months ago

0.7.1-beta.0

7 months ago

0.8.0-beta.0

7 months ago

0.8.0

7 months ago

0.7.1

7 months ago

0.7.0

8 months ago

0.6.1

1 year ago

0.6.0

1 year ago

0.5.1

2 years ago

0.5.0

2 years ago

0.4.2

2 years ago

0.4.1

2 years ago

0.3.0

2 years ago

0.4.0

2 years ago

0.3.1

2 years ago

0.2.3

2 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.1-beta.0

3 years ago

0.2.0

3 years ago

0.2.0-rc0

3 years ago

0.2.0-rc1

3 years ago

0.1.9-beta

3 years ago

0.1.9

3 years ago

0.1.7

3 years ago

0.0.14

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8-beta

4 years ago

0.0.8

4 years ago

0.0.7-beta

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago

0.0.1-beta

4 years ago