-
Notifications
You must be signed in to change notification settings - Fork 10
/
basic_example.py
33 lines (27 loc) · 1.76 KB
/
basic_example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import os
import json
from web3 import Web3
from web3_bridge import Web3Bridge
from chain import Chain
from fireblocks_sdk import FireblocksSDK, TransferPeerPath, TRANSACTION_STATUS_CONFIRMED, TRANSACTION_STATUS_CANCELLED, TRANSACTION_STATUS_REJECTED, TRANSACTION_STATUS_FAILED, VAULT_ACCOUNT,\
TRANSACTION_MINT, TRANSACTION_BURN, FireblocksApiException, DestinationTransferPeerPath, ONE_TIME_ADDRESS
w3 = Web3(Web3.EthereumTesterProvider())
print(w3.isConnected())
CHAIN = Chain.ROPSTEN
CONTRACT_ADDRESS = Web3.to_checksum_address("0xcbe74e21b070a979b9d6426b11e876d4cb618daf")
EIP20_ABI = json.loads('[{"constant":false,"inputs":[{"name":"_greeting","type":"string"}],"name":"greet","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getGreeting","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"}]')
GREETING = "Hello web3"
def create_contract_call_transaction(bridge: Web3Bridge, tx_data: dict):
resp = bridge.send_transaction(tx_data)
print(resp)
bridge.check_tx_is_completed(resp["id"])
if __name__ == '__main__':
api_secret = os.environ.get("FIREBLOCKS_API_SECRET_PATH")
fb_api_client = FireblocksSDK(api_secret, os.environ.get("FIREBLOCKS_API_KEY"), os.environ.get("FIREBLOCKS_API_BASE_URL"))
bridge = Web3Bridge(fb_api_client,
vault_account_id=os.environ.get("FIREBLOCKS_SOURCE_VAULT_ACCOUNT"),
external_wallet_address=os.environ.get("FIREBLOCKS_EXTERNAL_WALLET"),
chain=CHAIN)
contract = w3.eth.contract(address=CONTRACT_ADDRESS, abi=EIP20_ABI)
tx_data = contract.functions.greet(GREETING).buildTransaction()
create_contract_call_transaction(bridge, tx_data)