@abacus-network/sdk 中文文档教程

发布于 3年前 浏览 22 更新于 3年前

Abacus SDK

Abacus SDK 是一个管理系统 ethers.js 提供帮助的提供者和签名者 开发人员同时连接到多个网络。 它是一部分 Abacus 项目,但可能 对其他多链系统有用。

这个包包括 MultiProvider,以及一个 AbacusContext 与已部署的 Abacus 系统交互。 开发、暂存和主网 Abacus 系统具有用于快速开发的预构建对象。

Intended Usage

import * as ethers from 'ethers';

import { mainnet } from '@abacus-network/sdk';

// Set up providers and signers
const someEthersProvider = ethers.providers.WsProvider('...');
const someEthersSigner = new AnySigner(...);
mainnet.registerProvider('ethereum', someEthersProvider);
mainnet.registerSigner('ethereum', someEthersSigner);

// We have shortcuts for common provider/signer types
mainnet.registerRpcProvider('celo', 'https://forno.celo.org');
mainnet.registerWalletSigner('celo', '0xabcd...');

// Interact with the Abacus Bridge
// Send ETH from ethereum to celo
await mainnet.sendNative(
    'ethereum', // source
    'celo',  // destination
    ethers.constants.WeiPerEther, // amount
    '0x1234...',  // recipient
);

// Send Tokens from celo to ethereum
await mainnet.send(
    'celo',  // source
    'ethereum', // destination
    { domain: 'ethereum', id: "0xabcd..."} // token information
    ethers.constants.WeiPerEther, // amount
    '0x1234...'  // recipient
    { gasLimit: 300_000 } // standard ethers tx overrides
);

// so easy.

Abacus SDK

Abacus SDK is a management system for ethers.js providers and signers that helps developers connect to multiple networks simultaneously. It is part of the Abacus project, but may be useful to other multi-chain systems.

This package includes the MultiProvider, as well as an AbacusContext for interacting with deployed Abacus systems. The dev, staging, and mainnet Abacus systems have pre-built objects for quick development.

Intended Usage

import * as ethers from 'ethers';

import { mainnet } from '@abacus-network/sdk';

// Set up providers and signers
const someEthersProvider = ethers.providers.WsProvider('...');
const someEthersSigner = new AnySigner(...);
mainnet.registerProvider('ethereum', someEthersProvider);
mainnet.registerSigner('ethereum', someEthersSigner);

// We have shortcuts for common provider/signer types
mainnet.registerRpcProvider('celo', 'https://forno.celo.org');
mainnet.registerWalletSigner('celo', '0xabcd...');

// Interact with the Abacus Bridge
// Send ETH from ethereum to celo
await mainnet.sendNative(
    'ethereum', // source
    'celo',  // destination
    ethers.constants.WeiPerEther, // amount
    '0x1234...',  // recipient
);

// Send Tokens from celo to ethereum
await mainnet.send(
    'celo',  // source
    'ethereum', // destination
    { domain: 'ethereum', id: "0xabcd..."} // token information
    ethers.constants.WeiPerEther, // amount
    '0x1234...'  // recipient
    { gasLimit: 300_000 } // standard ethers tx overrides
);

// so easy.
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文