QQ 殖民地类型参考执行
@colony/colony-js
communityJS是一个 JavaScript 库,具有简单和可预测的接口,用于应用程序层集成 殖民地网络 智能合约. 为了了解更多殖民地,你可以去参观 殖民地.io 或读取 白皮书。 。 。 .
文档
你应该看看 getColonyNetworkClient 函数在 ColonyNetworkClient 和延长殖民地合同文件 clients/Colony/ColonyClientVX。 。 。 .
开始
import { providers, utils, Wallet } from 'ethers';
import { getColonyNetworkClient, ColonRpcEndpoint, Id, Network, Tokens } from '@colony/colony-js';
const { formatEther } = utils;
const provider = new providers.JsonRpcProvider(ColonyRpcEndpoint.ArbitrumOne);
const start = async () => {
// Get a wallet instance
const wallet = new Wallet(
// This is a random private key (don't use this one for anything else and _definitely_ do not send valuables to the corresponding address)
'0x0355596cdb5e5242ad082c4fe3f8bbe48c9dba843fe1f99dd8272f487e70efae',
provider,
);
// Check out the logs to see the wallet address
console.log('Wallet Address:', wallet.address);
// Get a network client instance for ArbitrumOne Chain
const networkClient = getColonyNetworkClient(
Network.ArbitrumOne,
wallet,
);
// Let's connect to the Meta Colony
const metaColonyClient = await networkClient.getMetaColonyClient()
// And check out it's CLNY funding
const funding = await metaColonyClient.getFundingPotBalance(Id.RootPot, Tokens.ArbitrumOne.CLNY);
// We can also see its address
const { address } = metaColonyClient;
console.info(`${formatEther(funding)} CLNY in root domain of MetaColony with address: ${address}`);
};
start();
太复杂了? 需要更多的指导吗?
尝试 殖民地 SDK。 。 。 .
许可证
GPL-3.0 (英语)