gpt4 book ai didi

nearprotocol - 关于如何使用 API 的 NEAR 协议(protocol) near-js-api 文档

转载 作者:行者123 更新时间:2023-12-05 06:11:19 24 4
gpt4 key购买 nike

我正在开发一个网络应用程序,并希望使用 near 按钮登录以通过网络钱包连接到网络,这样我的用户就可以调用网络中的合约。我找到了 https://corgis.near.org/ 上托管的 corgi 示例应用程序,这段代码看起来像是连接到网络钱包:https://github.com/nearprotocol/corgis/blob/master/src/index.js#L13

async function InitContract() {
const nearConfig = getConfig(process.env.NODE_ENV || "development");

// Initializing connection to the NEAR
const near = await nearlib.connect({
deps: {
keyStore: new nearlib.keyStores.BrowserLocalStorageKeyStore(),
},
...nearConfig,
});

// Needed to access wallet
const walletConnection = new nearlib.WalletConnection(near);

// Load in account data
let currentUser;
if (walletConnection.getAccountId()) {
currentUser = {
accountId: walletConnection.getAccountId(),
balance: (await walletConnection.account().state()).amount,
};
}

但我正在尝试为 https://github.com/near/near-api-js 查找一些文档库,它提供了更多关于事物如何工作的见解,例如连接到不同网络(测试网、测试网、主网)的选项是什么。

最佳答案

我找到了 near-api-js 的文档:https://near.github.io/near-api-js/其中解释了如何向要连接的网络提供 chainId:https://near.github.io/near-api-js/interfaces/_utils_network_.network.html .

关于nearprotocol - 关于如何使用 API 的 NEAR 协议(protocol) near-js-api 文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64048154/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com