So the new API only accepts a packed_trx but there is no RPC call to pack a signed transaction.

How can it be done on system without cleos installed? Is there any implementation in pure Python, NodeJS or PHP?


I ended up using https://github.com/OracleChain/chainkit/blob/master/chain/packedtransaction.cpp. This is my packtx.cpp:

#include <iostream>
#include <string>
#include "chain/packedtransaction.h"
#include <QDebug>

using namespace std;

int main(int argc, char *argv[])
        std::string jsonString;
        jsonString = argv[1];

        SignedTransaction signedTx;

        QByteArray jsonByte = QByteArray(jsonString.c_str(), jsonString.length());

        QJsonParseError error;
        QJsonDocument doc = QJsonDocument::fromJson(jsonByte, &error);
        QJsonObject jo = doc.object();

        if (jo.isEmpty()) {
           std::cout << "JSON object is empty." << std::endl;
           return false;

        QJsonValue value = jo.value(QString("transaction"));


        PackedTransaction packedtx(signedTx, "none");
        QJsonValue packedJson = packedtx.toJson();

        QJsonDocument tmpdoc(packedJson.toObject());
        QString strJson(tmpdoc.toJson(QJsonDocument::Compact));

        cout << strJson.toUtf8().constData() << endl;

You will need g++ with QT5 to compile it.

git clone https://github.com/OracleChain/chainkit
cd chainkit
rm test/main.cpp && rm utility/httpclient.cpp && rm utility/httpclient.h
vi packtx.cpp # copy&paste packtx.cpp source code
qmake -project
qmake chainkit.pro

Sample usage:

./chainkit '{"transaction":{"expiration": "2018-09-30T08:24:04","ref_block_num": 59970,"ref_block_prefix": 1935413997,"max_net_usage_words": 0,"max_cpu_usage_ms": 0,"delay_sec": 0,"context_free_actions": [],"actions": [{"account": "eosio.token","name": "transfer","authorization": [{"actor": "user2","permission":"active"}],"data":"00000000007115d600000000807115d601000000000000000447434e00000000046d656d6f"}],"transaction_extensions": []}}'

Sample output:


  • I also had to edit the file chain/transactionheader.cpp:21 removing the + EXPIRATION_SEC as we are already giving the expiration as future date.
    – Gotenks
    Nov 21 '18 at 17:05

RPC API could be helpful https://developers.eos.io/eosio-nodeos/reference#get_info For this is API, you need to forward an API point


You can use eosjs to process transaction. here is link https://github.com/EOSIO/eosjs

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.