import icon
import icon.builder
from icon.data import unit, Address
from icon.provider import HTTPProvider
from icon.wallet import KeyWallet
provider = HTTPProvider("http://localhost:9000", 3)
client = icon.Client(provider)
wallet = KeyWallet()
to = Address.from_string("hx0123456789012345678901234567890123456789")
try:
tx: icon.builder.Transaction = icon.builder.TransactionBuilder() \
.from_(wallet.address) \
.to(to) \
.value(unit.icx(10)) \
.step_limit(100_000) \
.nonce(0) \
.build()
tx.sign(wallet.private_key)
tx_hash: bytes = client.send_transaction(tx)
except icon.SDKException as e:
print(e)
- Estimate the quantity of steps required to process a transaction
from typing import Dict
import icon
provider = icon.HTTPProvider("https://localhost:9000")
client = icon.Client(provider)
wallet = icon.KeyWallet()
to = icon.Address.from_string("hx0123456789012345678901234567890123456789")
try:
params: Dict[str, str] = icon.TransactionBuilder() \
.from_(wallet.address) \
.to(to) \
.value(10 * 10 ** 18) \
.step_limit(100_000) \
.nonce(0) \
.build()
estimated_step: int = client.estimate_step(params)
except icon.SDKException as e:
print(e)
- Query block information with given block hash