0

In my private multi-node blockchain. There are 4 nodes. One genesis (only receives blocks) and Others (Produce and receive blocks). All nodes share the same genesis.json file. Inside genesis.json I have set the genesis node public key as the initial_key. All Nodes run nodeos with their respective keys using:

#!/bin/bash
DATADIR="./blockchain"
if [ ! -d $DATADIR ]; then
        mkdir -p $DATADIR; fi;
nodeos \
        --genesis-json $DATADIR"/../../genesis.json" \
        --signature-provider NODEPUBKEY=KEY:NODEPRIVKEY\
        --plugin eosio::producer_plugin \
        --plugin eosio::producer_api_plugin \
        --plugin eosio::chain_plugin \
        --plugin eosio::chain_api_plugin \
        --plugin eosio::http_plugin \
        --plugin eosio::history_api_plugin \
        --plugin eosio::history_plugin \
        --plugin eosio::net_api_plugin \
        --plugin eosio::net_plugin \
        --data-dir $DATADIR"/data" \
        --blocks-dir $DATADIR"/blocks" \
        --config-dir $DATADIR"/config" \
        --producer-name eosio \
        --http-server-address genesisip:8889 \
        --p2p-listen-endpoint genesisip:8888 \
        --access-control-allow-origin=* \
        --contracts-console \
        --http-validate-host=false \
        --verbose-http-errors \
        --enable-stale-production \
        --p2p-peer-address peer1IP:8888 \
        --p2p-peer-address peer2IP:8888 \
        --p2p-peer-address peer3IP:8888 \
        --max-transaction-time 1000 \
        --filter-on=* \
        >> $DATADIR"/nodeos.log" 2>&1 & \
        echo $! > $DATADIR"/eosd.pid":8888 \
    

Now I connect blockchain through EosSharp API. API is using the private key of the genesis node whose public key is set as an initial_key in genesis.json to sign transactions. My question is if I want to do transactions using the Peer3 private key, then do I need to change the initial_key as a public key of Peer3? Because currently, Web API is giving exception "UnAuthorised" for the key other than genesis.

1

I have the feeling your network and your producers are not configured correctly, with correct configuration your questions are probably unnecessary.

If you follow the eosio-bios-boot-sequence-tutorial your network should be set up correctly.

A few things regarding keys and signing in short.

  1. While setting up your network, you need to create one eos-account per peer, while doing so you can pass keys for active- and owner-permissions which you use to sign transactions.
  2. You have to register each of these accounts as producer via the regproducer-action and you can pass a signing key for signing blocks. This signing key should be different from the keys for the active- and owner-permission as one is used to sign transactions and the other is used to sign blocks.
  3. After correctly setting up your network you should be able to use the active- and owner-keys of any of your peers to sign transactions or to create new accounts to sign transactions and neither have to use the initial_key or the signer-key of any of your peers.
3
  • Hi, I have followed the bios-boot-sequence-tutorial completely, I have a set of key-pair separate for each peer. For each peer, I have used its key to create the account, set it as ``` --signature-provider``` , and used the same for regproducer-action
    – Varsh
    May 24 at 2:44
  • ok, you can do it that way, but it's not perfect. Anyway, once the accounts are created, you should be able to sign transactions with them. Of course you have to change the account name and the key in EosSharp. Does it work with any of your keys? Is the "Unauthorized" you mention a normal HTTP 401 statuscode or is it something that clearly comes from the nodeos-api?
    – cmadh
    May 24 at 19:42
  • Thank you, One thing I did is change the account name and the key in EosSharp and another remove require_auth(_self); from smart contract actions. Now it works.
    – Varsh
    May 28 at 3:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.