Exemple #1
0
account = Account(
    "cfac4f5fa828072ba8313b0686f02f576fa0fc8caba947569429e88968577865")
raw_tx, tx_hash = account.sign(tx)
# print("raw_tx = {}, tx_hash = {}".format(raw_tx, tx_hash))

cli.sendTransactions({tx_hash: raw_tx})
receipt = cli.getTransactionReceipt(tx_hash)
example_contract.setAddress(receipt['contractAddress'])
tx = example_contract.functions.func1(2).buildTransaction({
    'nonce': 2,
    'gas': 200000,
    'gasPrice': 100,
})
raw_tx, tx_hash = account.sign(tx)
cli.sendTransactions({tx_hash: raw_tx})

balance = cli.getBalance("1234567890123456789012345678901234567890", height=1)
print('balance = {}'.format(balance))

receipt = cli.getTransactionReceipt("1234567890123456789012345678901234567890")
print('receipt = {}'.format(receipt))

block = cli.getBlock(123)
print('block = {}'.format(block))

elem = cli.getContainerAt('1234567890123456789012345678901234567890',
                          'cid',
                          '1',
                          'array',
                          height=1)
print('elem = {}'.format(elem))
Exemple #2
0
import sys
sys.path.append('../../..')

from ammolite import (Cli, HTTPProvider, Account)
import time

cli = Cli(HTTPProvider('http://192.168.1.111:8080'))
acc_from = Account('316b4cb5409a7c8998c04ad81ffb5f771c70ae7305cbd976845c27320aa2fb36')
to_address1 = 'd024a83F83394B90AA2db581250Bc00B0B0f414a'
to_address2 = 'd7cB260c7658589fe68789F2d678e1e85F7e4831'

origin_balance_from = cli.getBalance(acc_from.address())
origin_balance_to1 = cli.getBalance(to_address1)
origin_balance_to2 = cli.getBalance(to_address2)
print('Before transfer:')
print(f'\tBalance of {acc_from.address()}: {origin_balance_from}')
print(f'\tBalance of {to_address1}: {origin_balance_to1}')
print(f'\tBalance of {to_address2}: {origin_balance_to2}')

raw_tx1, tx_hash1 = acc_from.sign({
    'nonce': 1,
    'value': origin_balance_from - 21000,
    'gas': 21000,
    'gasPrice': 1,
    'data': b'',
    'to': bytearray.fromhex(to_address1)
})
raw_tx2, tx_hash2 = acc_from.sign({
    'nonce': 2,
    'value': origin_balance_from - 21000,
    'gas': 21000,