3dcoin 中文文档教程

发布于 6年前 浏览 29 项目主页 更新于 3年前

node-3dcoin

npm下载js- standard-style

node-3dcoin 是 3dcoin 客户端的 JSON-RPC API 的简单包装器。

API相当于此处的API文档。 这些方法在 3dcoin.Client 上公开为小驼峰方法 对象,或者您可以直接使用 cmd 方法调用 API。

Install

npm i 3dcoin

Examples

Create client

// all config options are optional
var node_3dcoin = require('3dcoin');
var client = new node_3dcoin.Client({
  host: 'localhost',
  port: 'port',
  user: 'username',
  pass: 'password',
  timeout: 30000
});

Get balance across all accounts with minimum confirmations of 6

client.getBalance('*', 6, function(err, balance, resHeaders) {
  if (err) return console.log(err);
  console.log('Balance:', balance);
});

Getting the balance directly using cmd

client.cmd('getbalance', '*', 6, function(err, balance, resHeaders){
  if (err) return console.log(err);
  console.log('Balance:', balance);
});

Batch multiple RPC calls into single HTTP request

var batch = [];
for (var i = 0; i < 10; ++i) {
  batch.push({
    method: 'getnewaddress',
    params: ['myaccount']
  });
}
client.cmd(batch, function(err, address, resHeaders) {
  if (err) return console.log(err);
  console.log('Address:', address);
});

node-3dcoin

npmdownloadsjs-standard-style

node-3dcoin is a simple wrapper for the 3dcoin client's JSON-RPC API.

The API is equivalent to the API document here. The methods are exposed as lower camelcase methods on the 3dcoin.Client object, or you may call the API directly using the cmd method.

Install

npm i 3dcoin

Examples

Create client

// all config options are optional
var node_3dcoin = require('3dcoin');
var client = new node_3dcoin.Client({
  host: 'localhost',
  port: 'port',
  user: 'username',
  pass: 'password',
  timeout: 30000
});

Get balance across all accounts with minimum confirmations of 6

client.getBalance('*', 6, function(err, balance, resHeaders) {
  if (err) return console.log(err);
  console.log('Balance:', balance);
});

Getting the balance directly using cmd

client.cmd('getbalance', '*', 6, function(err, balance, resHeaders){
  if (err) return console.log(err);
  console.log('Balance:', balance);
});

Batch multiple RPC calls into single HTTP request

var batch = [];
for (var i = 0; i < 10; ++i) {
  batch.push({
    method: 'getnewaddress',
    params: ['myaccount']
  });
}
client.cmd(batch, function(err, address, resHeaders) {
  if (err) return console.log(err);
  console.log('Address:', address);
});
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文