Contract ABI Encoding
Go to file
Mark Spanbroek 767c4ab588 Decoding of basic types 2021-11-30 15:14:57 +01:00
.github/workflows Add CI 2021-11-25 09:33:40 +01:00
contractabi Decoding of basic types 2021-11-30 15:14:57 +01:00
tests Decoding of basic types 2021-11-30 15:14:57 +01:00
.editorconfig ABI Encoder extracted from nim-nitro module 2021-11-25 09:33:32 +01:00
.gitignore ABI Encoder extracted from nim-nitro module 2021-11-25 09:33:32 +01:00
.tool-versions ABI Encoder extracted from nim-nitro module 2021-11-25 09:33:32 +01:00
Readme.md ABI Encoder extracted from nim-nitro module 2021-11-25 09:33:32 +01:00
contractabi.nim Decoding of basic types 2021-11-30 15:14:57 +01:00
contractabi.nimble version 0.2.0 2021-11-30 09:43:28 +01:00
nim.cfg ABI Encoder extracted from nim-nitro module 2021-11-25 09:33:32 +01:00

Readme.md

Contract ABI

Implements encoding of parameters according to the Ethereum Contract ABI Specification.

Installation

Use the Nimble package manager to add contractabi to an existing project. Add the following to its .nimble file:

requires "https://github.com/status-im/nim-contract-abi >= 0.1.0 & < 0.2.0"

Usage

import contractabi
import stint

# encode unsigned integers, booleans, enums
AbiEncoder.encode(42'u8)

# encode uint256
AbiEncoder.encode(42.u256)

# encode byte arrays and sequences
AbiEncoder.encode([1'u8, 2'u8, 3'u8])
AbiEncoder.encode(@[1'u8, 2'u8, 3'u8])

# encode tuples
var encoder = AbiEncoder.init()
encoder.startTuple()
encoder.write(42'u8)
encoder.write(@[1'u8, 2'u8, 3'u8])
encoder.write(true)
encoder.finishTuple()
encoder.finish()