我正在开发一个web应用程序,希望有一个带有近端按钮的登录,以便通过web钱包连接到网络,这样我的用户就可以在网络中调用合同。我找到了托管在https://corgis.near.org/上的corgi示例应用程序,下面的代码看起来像是连接到web钱包: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库的一些文档,它提供了更多关于事物如何工作的见解,例如连接到不同网络(betanet,testnet,mainnet)的选项有哪些。
发布于 2020-09-25 07:06:08
我找到了near-api-js:https://near.github.io/near-api-js/的文档,它解释了如何为您想要连接的网络提供一个chainId:https://near.github.io/near-api-js/interfaces/_utils_network_.network.html。
https://stackoverflow.com/questions/64048154
复制相似问题