0.6.1-alpha • Published 7 months ago

@roninbuilders/contracts v0.6.1-alpha

Weekly downloads
-
License
-
Repository
-
Last release
7 months ago

Ronin Network Contracts

Contract ABIs for the Ronin Network.

Installation

npm install @roninnetwork/contracts
# or
pnpm add @roninnetwork/contracts
# or
bun add @roninnetwork/contracts

Usage

There are two ways to import contracts:

Import contracts individually (Recommended):

This is the recommended approach as it minimizes the bundle size for your application.

import MY_CONTRACT from '@roninbuilders/contracts/my_contract'; // Updated path
// or for CommonJS
const MY_CONTRACT = require('@roninbuilders/contracts/my_contract'); // Updated path

Import all contracts (Larger bundle size):

import { AXIE_PROXY, KATANA_ROUTER } from '@roninbuilders/contracts'

Contract Structure

Each contract export includes:

  • Contract ABI
  • Contract address
  • Metadata (name, deprecation status, creation date)

Example:

import AXIE_PROXY from '@roninbuilders/contracts/axie_proxy' // Updated path

console.log(AXIE_PROXY.address) // Contract address
console.log(AXIE_PROXY.abi) // Contract ABI
console.log(AXIE_PROXY.proxy_abi) // Proxy ABI
console.log(AXIE_PROXY.is_deprecated) // Deprecation status

Viem Example

Using viem to interact with contracts:

import { createPublicClient, http } from 'viem'
import AXIE_PROXY from '@roninbuilders/contracts/axie_proxy' // Updated path
import WRAPPED_ETHER from '@roninbuilders/contracts/wrapped_ether' // Updated path

const client = createPublicClient({
  chain: {
    id: 2020,
    name: 'Ronin',
    network: 'ronin',
    nativeCurrency: {
      decimals: 18,
      name: 'Ronin',
      symbol: 'RON'
    },
    rpcUrls: {
      default: { http: ['https://api.roninchain.com/rpc'] }
    }
  },
  transport: http()
})

// Read contract data
const balance = await client.readContract({
  address: WRAPPED_ETHER.address,
  abi: WRAPPED_ETHER.abi,
  functionName: 'balanceOf',
  args: [address]
})

Ethers Example

Using ethers.js to interact with contracts:

import { ethers } from 'ethers'
import AXIE_PROXY from '@roninbuilders/contracts/axie_proxy' // Updated path
import WRAPPED_ETHER from '@roninbuilders/contracts/wrapped_ether' // Updated path

const provider = new ethers.JsonRpcProvider('https://api.roninchain.com/rpc')

// Create contract instance
const contract = new ethers.Contract(
  WRAPPED_ETHER.address,
  WRAPPED_ETHER.abi,
  provider
)

// Read contract data
const balance = await contract.balanceOf(address)

Development

Update contracts from Ronin Explorer:

bun run update

Build the package:

bun run build

Format code:

bun run format

Contributing

See CONTRIBUTING.md for contribution guidelines.

0.4.9

11 months ago

0.4.8

12 months ago

0.6.0-alpha

7 months ago

0.1.0-alpha

8 months ago

0.6.1-alpha

7 months ago

1.0.0-alpha

8 months ago

0.5.0

11 months ago

0.5.2

9 months ago

0.5.1

10 months ago

0.4.7

1 year ago

0.4.6

1 year ago

0.3.9

1 year ago

0.3.10

1 year ago

0.4.5

1 year ago

0.4.4

1 year ago

0.4.1

1 year ago

0.4.0

1 year ago

0.4.3

1 year ago

0.4.2

1 year ago

0.3.7

2 years ago

0.3.6

2 years ago

0.3.5

2 years ago

0.3.4

2 years ago

0.3.3

2 years ago

0.3.2

2 years ago

0.3.0

2 years ago

0.2.3

2 years ago

0.3.1

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.0

2 years ago

0.1.11

2 years ago

0.1.1

2 years ago

0.0.5

2 years ago

0.0.41

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago