Skip to content

Binary <> JSON conversion using ABIs. Compatible with languages which can interface to C

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.txt
Notifications You must be signed in to change notification settings

SnaxFoundation/abisnax

 
 

Repository files navigation

abisnax

Binary <> JSON conversion using ABIs. Compatible with languages which can interface to C; see src/abisnax.h.

Alpha release. Feedback requested.

Packing transactions

  1. Create a context: abisnax_create
  2. Use abisnax_set_abi to load snaxjs2/src/transaction.abi into contract 0.
  3. Use abisnax_set_abi to load the contract's ABI.
  4. Use abisnax_json_to_bin and abisnax_get_bin_hex to convert action data to hex. Use abisnax_get_type_for_action to get the action's type.
  5. Use abisnax_json_to_bin and abisnax_get_bin_hex to convert transaction to hex. Use contract = 0 and type = abisnax_string_to_name(context, "transaction").
  6. Destroy the context: abisnax_destroy

Usage note

abisnax expects object attributes to be in order. It will complain about missing attributes if they are out of order.

Example data

Example action data for abisnax_json_to_bin:

{
    "from": "useraaaaaaaa",
    "to": "useraaaaaaab",
    "quantity": "0.0001 SNAX",
    "memo": ""
}

Example transaction data for abisnax_json_to_bin:

{
    "expiration": "2018-06-27T20:33:54.000",
    "ref_block_num": 45323,
    "ref_block_prefix": 2628749070,
    "max_net_usage_words": 0,
    "max_cpu_usage_ms": 0,
    "delay_sec": 0,
    "context_free_actions": [],
    "actions": [{
        "account": "snax.token",
        "name": "transfer",
        "authorization":[{
            "actor":"useraaaaaaaa",
            "permission":"active"
        }],
        "data":"608C31C6187315D6708C31C6187315D60100000000000000045359530000000000"
    }],
    "transaction_extensions":[]
}

Ubuntu 16.04 with gcc 8.1.0

  • Install these. You may have to build them yourself from source or find a PPA. Make them the default.
    • gcc 8.1.0
    • cmake 3.11.3
  • sudo apt install libboost-dev libboost-date-time-dev
  • remove this from CMakeLists.txt (2 places): -fsanitize=address,undefined
mkdir build
cd build
cmake ..
make
./test

Contributing

Contributing Guide

Code of Conduct

License

MIT

Important

See LICENSE for copyright and license terms. Block.one makes its contribution on a voluntary basis as a member of the SNAX community and is not responsible for ensuring the overall performance of the software or any related applications. We make no representation, warranty, guarantee or undertaking in respect of the software or any related documentation, whether expressed or implied, including but not limited to the warranties or merchantability, fitness for a particular purpose and noninfringement. In no event shall we be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or documentation or the use or other dealings in the software or documentation. Any test results or performance figures are indicative and will not reflect performance under all conditions. Any reference to any third party or third-party product, service or other resource is not an endorsement or recommendation by Block.one. We are not responsible, and disclaim any and all responsibility and liability, for your use of or reliance on any of these resources. Third-party resources may be updated, changed or terminated at any time, so the information here may be out of date or inaccurate.

About

Binary <> JSON conversion using ABIs. Compatible with languages which can interface to C

Resources

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.txt

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 85.4%
  • TypeScript 12.4%
  • C 1.3%
  • Other 0.9%