Jasmine Project Ethereum SDK (Python)
Project description
Jasmine Project Ethereum SDK (Python)
This SDK provides the following functionalities:
- Create/retrieve new/existing Ethereum accounts
- Transfer ETH and query ETH balance
- Deploy TFCManager smart contracts along with TFCToken ERC20 contracts.
- Claim TFC token through TFCManager using a signature signed by the TFCManager deployer account. Signing functionality is not provided in this SDK by now. Alternatively, use Golang SDK or JavaScript SDK.
- Perform ERC20 standard actions on TFC ERC20 token, including transfer, transferFrom and approve.
Installation
Requires Python >=3.6
pip install jasmine_eth
Usage
Instantiate an SDK object using Ethereum endpoint:
from jasmine_eth import SDK
sdk = SDK("http://localhost:8545")
Create/retrieve an Ethereum account
private_key = "0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d"
account = sdk.retrieve_account(private_key) # retrieve account using private key
account = sdk.create_account() # create a new account
print(account.address) # Ethereum address
print(account.private_key) # account private key
Deploy TFCManager contract, which will implicitly deploy TFCToken ERC20 contract.
# make sure the account have enough ETH balance to deploy contracts
manager_address = await sdk.deploy_tfc_manager(account)
Get the TFCManager contract instance and TFCToken contract instance:
manager = sdk.get_tfc_manager(manager_address)
tfc_erc20_address = manager.tfc_token_address()
tfc = sdk.get_tfc_token(tfc_erc20_address)
Claim TFC:
amount: int = 1000000000000000000 # 1 TFC
nonce: int = 0
signature: str = "0x6b04573d9a5b813e65b7afc77ca931bf1a5787ed1732622034355c75b39fe934194501f3431b2fed46581eaa486cdb636eebcb7f852d2105af4a4b53a25dd27e1c"
# account claim the amount of TFC using signature signed by TFCManager deployer
await manager.claim_tfc(amount, nonce, signature, account)
Get TFC balance
balance: int = tfc.balance_of(account.address)
Transfer TFC
amount: int = 1000000000000000000 # 1 TFC
await tfc.transfer(recipient_account.address, amount, account)
await tfc.approve(spender_account.address, amount, account)
await tfc.transfer_from(account.address, recipient_account.address, amount, spender_account)
Note: All methods that involve sending transactions are async functions and should be awaited.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jasmine_eth-0.0.5.tar.gz.
File metadata
- Download URL: jasmine_eth-0.0.5.tar.gz
- Upload date:
- Size: 14.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.0.0.post20201207 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.6.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aae03518ab0d19d810c8dc482f0ec70b60f1f42cf5ab17226ae08a4e9d8008c6
|
|
| MD5 |
c6282d173c8a1a4de4c1c1c7860cc8c9
|
|
| BLAKE2b-256 |
54d01773cca9b84d8e61969b0ad732ac99b330a4f5dbed3b505735329650c76f
|
File details
Details for the file jasmine_eth-0.0.5-py3-none-any.whl.
File metadata
- Download URL: jasmine_eth-0.0.5-py3-none-any.whl
- Upload date:
- Size: 22.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.0.0.post20201207 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.6.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1e02cadfc8a4ff1d14c7bbeca6523c63a68b0b51a124af8af0aca15978d8477
|
|
| MD5 |
6df051dc75e3874ac859c75e8aaae6a0
|
|
| BLAKE2b-256 |
ce1880827c4aca46e84f8971c3077c370f1c0b8c62e1d3c6f15aa40148b8c538
|