@bosonprotocol/instances
v1.6.0
Published
Utility package that contains the official contract addresses and ABIs of the [Boson Protocol](https://www.bosonprotocol.io/).
Downloads
19
Keywords
Readme
@bosonprotocol/instances
Utility package that contains the official contract addresses and ABIs of the Boson Protocol.
Installation
npm install @bosonprotocol/instances
# OR
yarn add @bosonprotocol/instances
Usage
The package contains addresses and ABIs of multiple protocol versions and environments/chains.
Import
You can directly import from a @bosonprotocol/instances/<PROTOCOL_VERSION>
module (available protocol versions are listed in the src/versions
folder) or use the top-level asynchronous get functions.
ESM
import { getContractAddresses } from "@bosonprotocol/instances/1.0.0";
import {
BosonRouterABI,
VouchersABI
} from "@bosonprotocol/instances/1.0.0/abis";
import {
getContractAddressesByVersion,
getAbiByVersion
} from "@bosonprotocol/instances";
CJS
const { getContractAddresses } = require("@bosonprotocol/instances/1.0.0");
const {
BosonRouterABI,
VouchersABI
} = require("@bosonprotocol/instances/1.0.0/abis");
const {
getContractAddressesByVersion,
getAbiByVersion
} = require("@bosonprotocol/instances");
Contract addresses
const addressesMainnetProduction = getContractAddresses({
chainId: 1,
env: "production"
});
const addressesRopstenTesting = getContractAddresses({
chainId: 3,
env: "testing"
});
const addressesByVersion = await getContractAddressesByVersion({
chainId: 3,
env: "testing",
protocolVersion: "1.0.0"
});
ABIs
Import directly from @bosonprotocol/instances/<PROTOCOL_VERSION>/abis
or use
const abi = await getAbiByVersion({
contractName: "BosonRouter",
protocolVersion: "1.0.0"
});
Contribution
In order to update or add addresses and ABIs of newer protocol versions or different environments/chains, checkout this repository and follow the steps below:
Install dependencies
npm install
Update or add source files
Addresses
If you want to update or add addresses run:
npm run update:addresses -- <SRC_FILE>
Note, that the <SRC_FILE>
should conform to the schema:
{
"chainId": "<CHAIN_ID>", // number
"env": "<ENV>", // optional string
"protocolVersion": "<PROTOCOL_VERSION>",
"<CONTRACT_NAME>": "<CONTRACT_ADDRESS>"
// ... other contract entries
}
If you run the deploy
script of the bosonprotocol/contracts
repo, then the outputted addresses file can be used as the <SRC_FILE>
:
# in the contracts repo
npx hardhat deploy --network rinkeby --env staging
# in the instances (this) repo
npm run update:addresses -- <PATH_TO_CONTRACTS_REPO>/addresses/4-staging.json
ABIs
To update the ABIs you can run:
npm run update:abis -- <PROTOCOL_VERSION>
This will install the @bosonprotocol/core
package and create the respective files in the src/versions/<PROTOCOL_VERSION>/abis
folder.
Create a PR
Commit the changes to a new branch and create a PR. Note, that we use Conventional Commits and Semantic Release to automatically publish and version the package. Therefore, if you update addresses the commit message should look something like
fix: addresses v1.0.0 staging ropsten
If you add new addresses or ABIs the commit message should look something like
feat: addresses v1.1.0 testing ropsten