GithubHelp home page GithubHelp logo

manifoldfinance / qabiencode Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 2.0 18 KB

KDB+ library for abi encoding ethereum functions

License: MIT License

Makefile 0.79% C 85.90% q 13.31%
q kdb kdb-library keccak ethereum blockchain

qabiencode's Introduction

qAbiEncode

KDB+ library for abi encoding ethereum functions. Specifications at:

https://docs.soliditylang.org/en/v0.5.3/abi-spec.html

Supports encoding of static and dynamic types. Fixed types have not been included as they are not currently used in our application.

Install

Download repo contents and compile C library e.g.

$ git clone https://github.com/manifoldfinance/qAbiEncode.git
$ cd qAbiEncode
$ make

Usage

Call .abi.encode, passing function signature and values i.e.

q)\l abi.q
q).abi.encode["sam(bytes,bool,uint256[])";("dave";1b;(1 2 3))]
0xa5643bf20000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000464617665000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003

Compare results with, https://docs.soliditylang.org/en/v0.5.3/abi-spec.html

or

https://abi.hashex.org/

qKeccak256

Ethereum Keccak C library for kdb+ integration. Ethereum sha3 differs from modern sha3 in the padding constant;

padding (keccak) = 0x01

padding (sha3) = 0x06

Modified from the original sha3 library at:

https://github.com/mjosaarinen/tiny_sha3 by Dr. Markku-Juhani O. Saarinen

based on Keccak algo: https://keccak.team/keccak_specs_summary.html

Keccak Usage

q)sha3: `qKeccak 2:(`qKeccak256;2)
q)sha3["sam(bytes,bool,uint256[])";count "sam(bytes,bool,uint256[])"]
0xa5643bf27e2786816613d3eeb0b62650200b5a98766dfcfd4428f296fb56d043

qabiencode's People

Contributors

sandybradley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

sambacha xtuyaowu

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.