# @nibiruchain/solidity
Nibiru EVM solidity contracts and ABIs for Nibiru-specific precompiles and core protocol functionality.
# Install
Solidity code is in "@nibiruchain/solidity/contracts/*
", and
ABI JSON files are in "@nibiruchain/solidity/abi/*
".
# ABI Files
Since contract ABIs are exported in JSON format, these ABIs can be used with any Ethereum-compatible JS library, such as:
- Viem
- Ethers.js
- Web3.js
- Hardhat or Foundry
# Usage in Solidity
This package exports interfaces, types, and constants for each Nibiru-specific precompiled contract (opens new window). To use these precompiles in Solidity, use the exported constant that represents an instance of the precompile.
For example in "IOracle.sol", we define:
This means another contract can use NIBIRU_ORACLE
to access each method from
the Nibiru Oracle precompile.
Similarly, the fungible token precompile defines:
So, you import this in your contract
# Usage with Typechain for Ethers v6
Often when building an application using Ethers.js, we want type-safe contract
interactions. The typechain
and @typechain/ethers-v6
packages are a useful
tool to generate TypeScript code an ethers.Contract
directly from smart
contract ABIs.
To generate ethers
TypeScript bindings for the ABIs exported from
the @nibiruchain/solidity
package, first install the required dependencies:
Then, you can generate like so.
This ensures contract interactions are type-checked at compile-time, helping reduce the likelihood of runtime errors.