使用Near-lib创建新的NEAR帐户-JsonRpcProvider问题

时间:2019-11-06 00:50:50

标签: javascript nearprotocol

当前正在阅读文档,并尝试提出一个可行的示例来创建一个新帐户,JsonRpcProvider遇到了一些问题-希望在此处发布完整的示例,因为我认为它对任何搜索者都有用

const keyStore = new nearLib.keyStores.UnencryptedFileSystemKeyStore('/path/to/file.txt');

const provider = new nearLib.providers.JsonRpcProvider('default') // TAKES URL
const signer = new nearLib.InMemorySigner(keyStore)

const connection = new nearLib.Connection("default", provider, signer);
const master_account = new nearLib.Account(connection, 'chicken');
const local_creator = new nearLib.accountCreator.LocalAccountCreator(master_account, 1000000000000);

const newAccount = await local_creator.createAccount('new_account_id',nearLib.utils.KeyPairEd25519.fromRandom().toString())

不确定要传递到provider的URL是什么!

1 个答案:

答案 0 :(得分:2)

网络网址,例如我们的测试网:https://rpc.nearprotocol.com