BCHD Fountainhead

bchd is an alternative full node bitcoin cash implementation written in Go (golang) that allows for easy querying of the blockchain. It may be used as an alternative to rest.bitcoin.com. bchd on fountainhead supports slp.

We provide public access via gRPC at bchd.fountainhead.cash:443 and REST with a limit of 10 reqs/second.

Get raw transaction

Using grpc-bchrpc-node we are able to to query txid 1155..a7e8 and receive back corresponding raw tx data.

const GrpcClient = require('grpc-bchrpc-node');
const grpc = new GrpcClient.GrpcClient({ url: 'bchd.fountainhead.cash:443' });

const txid = '11556da6ee3cb1d14727b3a8f4b37093b6fecd2bc7d577a02b4e98b7be58a7e8';
grpc.getRawTransaction({ hash: txid, reversedHashOrder: true })
.then(res => {
  const txdata = Buffer.from(res.getTransaction_asU8()).toString('hex');
  console.log(txdata);
});

Take note of the reversedHashOrder parameter.

Get raw block

Getting raw block is very similar to getting raw transaction above.

const GrpcClient = require('grpc-bchrpc-node');
const grpc = new GrpcClient.GrpcClient({ url: 'bchd.fountainhead.cash:443' });

// load from block hash using hash parameter
const block_hash = '0000000000000000004bdf1a301bec2ceaf314d53600cf1a4fc43222b267d7a8';
grpc.getRawBlock({ hash: block_hash, reversedHashOrder: true })
.then(res => {
  console.log(Buffer.from(res.getBlock_asU8()).toString('hex'));
});

// load from block height using index parameter
const block_height = 600123;
grpc.getRawBlock({ index: block_height })
.then(res => {
  console.log(Buffer.from(res.getBlock_asU8()).toString('hex'));
});

Take note of the reversedHashOrder parameter.

Get UTXOs for an address

If we are implementing a wallet it is very important to get a list of UTXOs associated with an address.

const GrpcClient = require('grpc-bchrpc-node');
const grpc = new GrpcClient.GrpcClient({ url: 'bchd.fountainhead.cash:443' });
const address = 'bitcoincash:qrcuqadqrzp2uztjl9wn5sthepkg22majyxw4gmv6p';
grpc.getAddressUtxos({ address: address, includeMempool: true })
.then(res => {
  res.getOutputsList().forEach(output => {
    const outpoint = output.getOutpoint();
    const obj = {
      txid:          Buffer.from(outpoint.getHash_asU8().reverse()).toString('hex'),
      vout:          outpoint.getIndex(),
      value:         output.getValue(),
      pubkey_script: Buffer.from(output.getPubkeyScript_asU8()).toString('hex'),
      block_height:  output.getBlockHeight(),
      coinbase:      output.getIsCoinbase(),
    };
    console.log(obj);
  });
});

Notice how we must reverse the txid, this is because bchd uses bitcoin's reverse format.

Broadcast transaction

Let's show an example of creating a transaction with bitcore-lib-cash and broadcasting with bchd.

const GrpcClient = require('grpc-bchrpc-node');
const bitcore = require('bitcore-lib-cash');

const grpc = new GrpcClient.GrpcClient({ url: 'bchd.fountainhead.cash:443' });

const privateKey = new bitcore.PrivateKey('L1uyy5qTuGrVXrmrsvHWHgVzW9kKdrp27wBC7Vs6nZDTF2BRUVwy');
const utxo = {
  txId:        '115e8f72f39fad874cfab0deed11a80f24f967a84079fb56ddf53ea02e308986',
  outputIndex: 0,
  address:     'bitcoincash:qprcvtlpvhnpyxhcp4wau8ktg78dzuzktvetlc7g9s',
  script:      '76a91447862fe165e6121af80d5dde1ecb478ed170565b88ac',
  satoshis:    50000
};

const txdata = new bitcore.Transaction()
  .from(utxo)
  .to('bitcoincash:qzkkrr85xvankfy0jazw36qak2ty6zhrjugpet7mt3', 15000)
  .sign(privateKey)
  .serialize();

grpc.submitTransaction({ txnHex: txdata })
.then(res => {
  console.log(res);
});

Note: this will not work, you will need your own UTXO and your own private key :)

Get blockchain info

We might want to query the node to get latest block information or information about bchd.

const GrpcClient = require('grpc-bchrpc-node');
const grpc = new GrpcClient.GrpcClient({ url: 'bchd.fountainhead.cash:443' });
grpc.getBlockchainInfo()
.then(res => {
  const obj = {
    net:               res.getBitcoinNet(),
    best_block_height: res.getBestHeight(),
    best_block_hash:   Buffer.from(res.getBestBlockHash_asU8().reverse()).toString('hex'),
    difficulty:        res.getDifficulty(),
    median_time:       res.getMedianTime(),
    tx_index:          res.getTxIndex(),
    addr_index:        res.getAddrIndex()
  };
  console.log(obj);
});

Notice how we must reverse the block hash for same reason as txhash.

Other Servers

List of other public servers to keep for redundancy: