bytecoin

Communicate with bytecoin via JSON-RPC

Usage no npm install needed!

<script type="module">
  import bytecoin from 'https://cdn.skypack.dev/bytecoin';
</script>

README

node-bytecoin

Bytecoin RPC client (Bytecoin-Wallet-Daemon-JSON-RPC-AP)[https://github.com/bcndev/bytecoin/wiki/Bytecoin-Wallet-Daemon-JSON-RPC-API#methods]

Install

npm install bytecoin
export RPC_USER=username
export RPC_PASS=password

Started Rpc Api

const { Rpc } = require('bytecoin');

const api = new Rpc({
  bindAddress: 'http://0.0.0.0:8070' // bind address
});

Use Api

api.createAddresses({ secret_spend_keys: [''] }).then(({ data: { result } }) => {
  console.log(result)
  /*
    "addresses": [
      "232A9qxGyKLanKmP7Q9TBA6Jv1tPx5AxM3ExRFhSijaVYVY4FtboZDSfortdXLzEqZQkan6xqXb73XiJND3tqnQY6yJMXXL"
    ],
    "secret_spend_keys": [
      "5506af58782aaae7603d80bcca0785affa2289e70242624eb3af28f8ca03bb02"
    ]
  */
})

Send Money

const from = '28QWenkKDen7cVbcfULxmk5g15gwWvjKYe8MXj8Ccgsvb6MYiXcEyQMZPdFbg6NFsXGmmRwDx2ofZTKjR8shojBLTKGVfQK';
const to = '27HTiGScRW1eUbawbmdNCcBThtVFYBDAL4j9XV4drPVcBh2EDBnBRwKfNCezqRpKfLJf5dmANoy6uA2bGtZ3uT5fJGqgzX8';

// create transaction
api.createTransaction(from, to, 1000000).then(({ data: { result } }) => {

  // send
  api.sendTransaction({ binary_transaction: result.binary_transaction })
})

Get Ballance

api.getBalance({ address: from }).then(({ data }) => {
  console.log(data)
})