Introduction
The Arbitrum SDK is a powerful TypeScript library that streamlines interactions with Arbitrum networks. It offers robust tools for bridging tokens and passing messages between networks through an intuitive interface to the underlying smart contracts.
Key Features
- Token Bridging: Effortlessly bridge tokens between Ethereum and Arbitrum.
- Message Passing: Seamlessly pass messages across networks.
- Contracts Interface: Leverage a strongly-typed interface for interacting with smart contracts.
Below is an overview of the Arbitrum SDK functionality. See the tutorials for more examples.
Getting Started
Install dependencies
- npm
- yarn
- pnpm
npm install @arbitrum/sdk
yarn add @arbitrum/sdk
pnpm install @arbitrum/sdk
Using the Arbitrum SDK
Bridging assets
Arbitrum SDK can be used to bridge assets to or from an Arbitrum Network. The following asset bridgers are currently available:
All asset bridgers have the following methods which accept different parameters depending on the asset bridger type:
deposit- moves assets from the Parent to the Child chainwithdraw- moves assets from the Child to the Parent chain
Example ETH Deposit to Arbitrum One
import { getArbitrumNetwork, EthBridger } from '@arbitrum/sdk'
// get the `@arbitrum/sdk` ArbitrumNetwork object using the chain id of the Arbitrum One chain
const childNetwork = await getArbitrumNetwork(42161)
const ethBridger = new EthBridger(childNetwork)
const ethDepositTxResponse = await ethBridger.deposit({
amount: utils.parseEther('23'),
parentSigner, // an ethers v5 signer connected to mainnet ethereum
childProvider, // an ethers v5 provider connected to Arbitrum One
})
const ethDepositTxReceipt = await ethDepositTxResponse.wait()
Learn more in the Eth Deposit tutorial
Example ETH Withdrawal from Arbitrum One
import { getArbitrumNetwork, EthBridger } from '@arbitrum/sdk'
// get the `@arbitrum/sdk` ArbitrumNetwork object using the chain id of the Arbitrum One chain
const childNetwork = await getArbitrumNetwork(42161)
const ethBridger = new EthBridger(childNetwork)
const withdrawTx = await ethBridger.withdraw({
amount: utils.parseEther('23'),
childSigner, // an ethers v5 signer connected to Arbitrum One
destinationAddress: childWallet.address,
})
const withdrawRec = await withdrawTx.wait()
Learn more in the Eth Withdraw tutorial