- [Contract](#contract)
- [get_events](#get_eventsstart_block_num-to_block_num-event_id)
- [FunctionCoder](#functioncoder)
- [encode_function](#encode_functionfunction_name-args)
- [decode_result](#decode_resultself-function_name-data)
- [EventDecoder](#eventdecoder)
- [decode_event](#decode_eventlog)
# Contract
```py
from vecha import Contract
contract = Contract(endpoint, address, abi_list)
```
**Parameters**:
- **endpoint**: `str`, thor restful server
- **address**: `str`, contract address
- **abi_list**: `List[Dict]`, contract abi
Then you can call the function directly on the contract instance via the function name in abi.
The following function names are built in, so the same name function in the smart contract will not be called.
```
get_events
decode_event
encode_function
decode_result
call
send
_request_events
```
In a smart contract, the function can be a call or a transaction. A transaction must provide private key.
```py
contract.you_name(*args, caller=None, value=0) # a call
contract.you_name(*args, pk, value) # a transaction
```
You can display the transaction as a call, this may help you debug smart contract.
```py
contract.you_name.call(*args, caller=None, value=0)
```
## `get_events(start_block_num, to_block_num, event_id)`
**Parameters**:
- **start_block_num** (optional): `int`, default is from genesis block
- **to_block_num** (optional): `int`, default is to best block
- **event_id** (optional): `str`, the signature of the event you want to filter out, default is all events of this contract
**Returns**:
- `List[Event]`, A list of Events. Event is a `namedtuple`, and it has three fields:
- event.name: `str`
- event.args: `Dict`, actual parameters when the event is emited
- event.block: `int`, the block number when the event is emited
> If you want to parse a log directly, please use [`EventDecoder.decode_event`](#decode_eventlog).<br>
> If you want to get an unsigned transaction data, you can use [`FunctionCoder.encode_function`](#encode_functionfunction_name-args).
# FunctionCoder
```py
from vecha import FunctionCoder
fn_coder = FunctionCoder(*fn_abi_list)
```
## `encode_function(function_name, *args)`
**Parameters**:
- **function_name**: `str`
- **args**: variable-length argument list of actual parameters
**Returns**:
- `str`, the data of a transaction that has not been signed
## `decode_result(self, function_name, data)`
# EventDecoder
```py
from vecha import EventDecoder
ev_decoder = EventDecoder(*event_abi_list)
```
## `decode_event(log)`
**Parameters**:
- **log**: `Dict`, the result of thor restful api `/logs/event`
**Returns**:
- `Event`, Event is a `namedtuple`, and it has three fields:
- event.name: `str`
- event.args: `Dict`, actual parameters when the event is emited
- event.block: `int`, the block number when the event is emited
- [get_events](#get_eventsstart_block_num-to_block_num-event_id)
- [FunctionCoder](#functioncoder)
- [encode_function](#encode_functionfunction_name-args)
- [decode_result](#decode_resultself-function_name-data)
- [EventDecoder](#eventdecoder)
- [decode_event](#decode_eventlog)
# Contract
```py
from vecha import Contract
contract = Contract(endpoint, address, abi_list)
```
**Parameters**:
- **endpoint**: `str`, thor restful server
- **address**: `str`, contract address
- **abi_list**: `List[Dict]`, contract abi
Then you can call the function directly on the contract instance via the function name in abi.
The following function names are built in, so the same name function in the smart contract will not be called.
```
get_events
decode_event
encode_function
decode_result
call
send
_request_events
```
In a smart contract, the function can be a call or a transaction. A transaction must provide private key.
```py
contract.you_name(*args, caller=None, value=0) # a call
contract.you_name(*args, pk, value) # a transaction
```
You can display the transaction as a call, this may help you debug smart contract.
```py
contract.you_name.call(*args, caller=None, value=0)
```
## `get_events(start_block_num, to_block_num, event_id)`
**Parameters**:
- **start_block_num** (optional): `int`, default is from genesis block
- **to_block_num** (optional): `int`, default is to best block
- **event_id** (optional): `str`, the signature of the event you want to filter out, default is all events of this contract
**Returns**:
- `List[Event]`, A list of Events. Event is a `namedtuple`, and it has three fields:
- event.name: `str`
- event.args: `Dict`, actual parameters when the event is emited
- event.block: `int`, the block number when the event is emited
> If you want to parse a log directly, please use [`EventDecoder.decode_event`](#decode_eventlog).<br>
> If you want to get an unsigned transaction data, you can use [`FunctionCoder.encode_function`](#encode_functionfunction_name-args).
# FunctionCoder
```py
from vecha import FunctionCoder
fn_coder = FunctionCoder(*fn_abi_list)
```
## `encode_function(function_name, *args)`
**Parameters**:
- **function_name**: `str`
- **args**: variable-length argument list of actual parameters
**Returns**:
- `str`, the data of a transaction that has not been signed
## `decode_result(self, function_name, data)`
# EventDecoder
```py
from vecha import EventDecoder
ev_decoder = EventDecoder(*event_abi_list)
```
## `decode_event(log)`
**Parameters**:
- **log**: `Dict`, the result of thor restful api `/logs/event`
**Returns**:
- `Event`, Event is a `namedtuple`, and it has three fields:
- event.name: `str`
- event.args: `Dict`, actual parameters when the event is emited
- event.block: `int`, the block number when the event is emited
Metadata
Release files for vecha 0.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| vecha-0.0.0.tar.gz | 15.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| vecha-0.0.0-py36-none-any.whl | Python 3.6 | none | any | Details |
Total release size: 33.6 kB
Release files / vecha-0.0.0.tar.gz
| Download URL | vecha-0.0.0.tar.gz |
|---|---|
| Size | 15.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
523c8bee836deacfdd9a848e6e15e6f7592a919b2add336177fa8917c8dfbc1b
|
|
BLAKE2b-256 checksum How to use checksums |
8ac90273d62f0513bd94a090a0288f4a9b5bdd78db7e438545982a03099fd2b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
|
Release files / vecha-0.0.0-py36-none-any.whl
| Download URL | vecha-0.0.0-py36-none-any.whl |
|---|---|
| Size | 18.0 kB |
| Tags | Python 3.6 |
|
SHA-256 checksum How to use checksums |
dec1c1320295b0bb722ccb41e918fe5693a05534ae95db437a7a84beeaf51d30
|
|
BLAKE2b-256 checksum How to use checksums |
1456d187441076dd240ae7c0c2e8ad734b8a855dc000fb4f9d0dd0d7d851fa95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
|