2

my Code

    var EosApi = require('eosjs-api');
const Eos = require("eosjs");
// ./cleos create key #OwnerKey
// Private key: 5KVihg2u3yZpBtoLhRGvqf6vBsq9swjyvUkvbpMVMQWz11NbMa2
// Public key: EOS6XViVfWJjLNBkpyPKguP5N3X9Q48mcBezVCPFdkWetFDikNvfR

//  ./cleos create key #ActiveKey
// Private key: 5KKdeNLjW8D9jAAAQFaioshPDci61LKda3DoY3Btzm4evkVooNV
// Public key: EOS6jB1PPcit1t3b9jxMWtzRQ5fTRr1UBHEN67u8yWzPJTQJDUktE

var PrivateOwnerWif = "5KVihg2u3yZpBtoLhRGvqf6vBsq9swjyvUkvbpMVMQWz11NbMa2";
var PublicOwnerWif = "EOS6XViVfWJjLNBkpyPKguP5N3X9Q48mcBezVCPFdkWetFDikNvfR";
var PrivateActiveWif = "5KKdeNLjW8D9jAAAQFaioshPDci61LKda3DoY3Btzm4evkVooNV";
var PublicActiveWif = "EOS6jB1PPcit1t3b9jxMWtzRQ5fTRr1UBHEN67u8yWzPJTQJDUktE";


currencyPrivate = '5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3'
davidPrivate = '5K8jzjyYymX6y3Ltj5r5MzzM3zq6eqeAiiZ3NBexCaAu5Vst43N'
davidPublic = 'EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV'

keyProvider = davidPrivate
chainId = 'cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f'
const Config = {
    httpEndpoint: 'http://192.168.1.10:8888',
    keyProvider: keyProvider,
    chainId: 'cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f',
    expireInSeconds: 60,
    broadcast: true,
    verbose: true,
    sign: true,
    logger: { // Default logging functions
        log: console.log,
        error: console.error
    },
    fetchConfiguration: {}
}
var eos = Eos(Config);
let { ecc } = Eos.modules
// Prepare headers
expireInSeconds = 60 * 60 // 1 hour

transferINVO = async () => {
    info = await eos.getInfo({})
    chainDate = new Date(info.head_block_time + 'Z')
    expiration = new Date(chainDate.getTime() + expireInSeconds * 1000)
    expiration = expiration.toISOString().split('.')[0]

    block = await eos.getBlock(info.last_irreversible_block_num)

    transactionHeaders = {
        expiration,
        ref_block_num: info.last_irreversible_block_num & 0xFFFF,
        ref_block_prefix: block.ref_block_prefix
    }

    keyProvider = davidPrivate
    // keyProvider=currencyPrivate

    // OFFLINE (bring `transactionHeaders`)

    // All keys in keyProvider will sign.
    eos = Eos({ httpEndpoint: null, chainId, keyProvider, transactionHeaders })

    transfer = await eos.transfer('david', 'reza', '0.0001 INV', '')
    transferTransaction = transfer.transaction


    //Online
    eos = Eos({ httpEndpoint: 'http://192.168.1.10:8888', chainId, keyProvider, transactionHeaders })

    processedTransaction = await eos.pushTransaction(transferTransaction)


    // cleos version:
    const cleosTransaction = transferTransaction.transaction
    cleosTransaction.signatures = transferTransaction.signatures
    // `cloes push transaction ${JSON.stringify(cleosTransaction)}`
}

transferINVO()

have error

{
    "code": 500,
    "message": "Internal Service Error",
    "error": {
        "code": 3090003,
        "name": "unsatisfied_authorization",
        "what": "Provided keys, permissions, and delays do not satisfy declared authorizations",
        "details": [
            {
                "message": "transaction declares authority '{\"actor\":\"david\",\"permission\":\"active\"}', but does not have signatures for it under a provided delay of 0 ms, provided permissions [], and provided keys [\"EOS53xNMpBLvJmXgUsgSAamFkhKMKdJun8nbktXMmg6zfeHSTzHye\"]",
                "file": "authorization_manager.cpp",
                "line_number": 411,
                "method": "check_authorization"
            }
        ]
    }
}
  • Did you import the keys in your wallet and keep it unlocked? – Rajat Chaudhary Sep 1 '18 at 15:51
2

You are not providing signature signing your transaction. It says you are trying to push it as david@active, but to not have authorization attached. Try adding the following options to your transaction construction.

const options = {
    authorization: 'david@active',
    broadcast: false,
    sign: false,
  };
|improve this answer|||||
  • was it helpful? can you please mark as correct answer or provide a feedback? – Lonkly Sep 9 '18 at 21:24
  • 1
    when transferring the symbol, private_key for sign transaction must belong to from_account(david) and contract_account(eosio.token) must belong to the symbol(INV). This solved my problem – metaboy Sep 11 '18 at 19:34

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.