Skip to main content

CartesiNexus

CartesiNexus is a Python library for handling blockchain-related operations, particularly focused on Cartesi ecosystem. It provides utilities for creating and managing various types of blockchain outputs and managing token transactions(withdrawing,transferring and depositing of assets).

Why this?

This library was created to give me an insight of how the cartesi ecosystem works at a certain level,also it was created due to the small number of cartesi library that is available,hence this library quickly get you up to speed. At the moment the library covers most operations on ether,erc20 and erc721 tokens.

Features

  • Handle Ether, ERC20, and ERC721 token operations(more tokens would soon be supported)
  • Manages assets for different token types
  • Create and manage outputs(Notices,Reports,Vouchers)
  • Encode and decode ABI payloads for token transactions

Installation

Using pip

     
     pip install cartesi-nexus

From GitHub

To get started with cartesi-nexus , clone this repository and install the required dependencies.

git clone https://github.com/jerrygeorge360/cartesi-nexus
cd cartesi_nexus
pip install -r requirements.txt

Usage

To import the necessary methods

from cartesi-nexus import str2hex,hex2str,withdraw,get_token,deposit,get_all_token

Checking Balance

To retrieve the balance information for a specific asset, use the get_token method,for all the assets for a specific address use get_all_token. This method should be called within the inspect function:

data = get_token(account:str,token_name:str)

to get all tokens related to an address

data = get_all_token(account:str)

Asset Handling Methods

For operations such as deposits, transfers and withdrawals, use the methods inside the handle_advance function.

Deposits

To process a deposit, ensure the sender is the designated portals smart contract (e.g., the default ERC20Portal smart contract from sunodo or nonodo when running locally). You might need to adjust the smart contract address based on your deployment or dynamically retrieve it from a resource file:

Withdrawal

To withdraw an asset

    withdraw_ether = withdraw_obj(FuncSel.ETHER,'0xadress',200)
    withdraw_erc20 = withdraw(FuncSel.ERC_20,'0xaddress',200)
    withdraw_20_to = withdraw(FuncSel.ERC_20_DIFF,'0xaddress',200,'0xaddress1')
    withdraw_erc721 = withdraw(FuncSel.ERC_721,'0xaddress',200,'0xaddress1')

where FuncSel is an enum that provides the type of asset

  • FuncSel.ETHER
  • FuncSel.ERC20
  • FuncSel.ERC721
  • FuncSel.ERC_20_DIFF

Transfer

This operation transfers tokens within the Dapp ecosystem. The method transfer is used to initiate the operation the payload should be formatted in the form and then converted to a hex string

payload = {'method': 'transfer', 'payload': {'sender_address': sender_address, 'destination_address': dest, 'amount': amount, 'data': args}}

transfer(token_type: str, payload) where token type is the asset(eth,erc20,erc721) where payload is in hex format.

transfer('eth',payload)
transfer('erc20',payload)
transfer('erc721,payload) 

Hex to String Conversions

The two methods for this are: str2hex and hex2str

from cartesi_nexus.helpers import str2hex,hex2str

converted_string = hex2str(payload)
converted_hex = str2hex(payload)

Metadata

Release files for cartesi-nexus 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cartesi-nexus 0.1.0
File Size Uploaded
cartesi_nexus-0.1.0.tar.gz 6.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cartesi-nexus 0.1.0
File Interpreter ABI Platform
cartesi_nexus-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.7 kB

Release files / cartesi_nexus-0.1.0.tar.gz

Download URL cartesi_nexus-0.1.0.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e6235ec253ade6fc5c6bd08e501dc5666ca1e092caa54a2f124e4601abd2b271
BLAKE2b-256 checksum
How to use checksums
480d01529495a7c7be1b2aba0575ef247304f7c1a2c020f13239db820a1747e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release files / cartesi_nexus-0.1.0-py3-none-any.whl

Download URL cartesi_nexus-0.1.0-py3-none-any.whl
Size 2.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
db679c6bbaac0bfdc5c759883e51e39996651d956ccd0785b7aa229daee60621
BLAKE2b-256 checksum
How to use checksums
220d3d23cd38457a79471bb6196d4b74cc498b1fbcaed8d9ec2a27dfabb50e95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page