基于盐而不是nonce的钱包。
bifrost-p的Python项目详细描述
双峰
重要:正在工作。没有生产软件。
总有机碳
安装
从pypi安装
# Virtualenv
(pyenv)$ pip install bifrost
# Main Python shell
$ sudo -H pip install bifrost
从源安装
# Ubuntu 18.04+# Required packages sudo apt install -y python3-dev git virtualenv # Create and activate virtualenv $ virtualenv -p python3 pyenv (pyenv) $ source pyenv/bin/activate # clone Repo(pyenv) $ git clone https://gitlab.com/dtecdeal/lab/bifrost /path/to/destination/folder (pyenv) $ cd /path/to/destination/folder/Python (pyenv) $ python setup.py install
用法
创建钱包
importosfromweb3importWeb3frombifrostimportBifrostSIGNER_PK=os.environ.get('SIGNER_PK',"{default-signer-pk}")FACTORY_ADDRESS=os.environ.get('FACTORY_ADDRESS',"{default-factory-address}")RPC_URL=os.environ.get('RPC_URL',"{default-RPC-URL}")BIFROST_FACTORY=os.environ.get('BIFROST_FACTORY',"{bifrost-factory}")w3Provider=Web3.HTTPProvider(RPC_URL)w3=Web3(w3Provider)signer_account=w3.eth.account.privateKeyToAccount(SIGNER_PK)bifrost=Bifrost(BIFROST_FACTORY,signer_account,w3Provider)address_salt=1address=bifrost.getAddress(address_salt)address_is_deployed=bifrost.isDeployed(address_salt)print(''' Signer: %s Salt: %s Address: %s IsDeployed: %s'''%(signer_account.address,address_salt,address,address_is_deployed))
传输ETH
importosfromweb3importWeb3frombifrostimportBifrostSIGNER_PK=os.environ.get('SIGNER_PK',"{default-signer-pk}")FACTORY_ADDRESS=os.environ.get('FACTORY_ADDRESS',"{default-factory-address}")RPC_URL=os.environ.get('RPC_URL',"{default-RPC-URL}")BIFROST_FACTORY=os.environ.get('BIFROST_FACTORY',"{bifrost-factory}")w3Provider=Web3.HTTPProvider(RPC_URL)w3=Web3(w3Provider)signer_account=w3.eth.account.privateKeyToAccount(SIGNER_PK)bifrost=Bifrost(BIFROST_FACTORY,signer_account,w3Provider)address_salt=1amount=int(.1*10**18)# Transfer ETH# address should have more than .1 (amount) ETHtx=bifrost.makeCall(address_salt,signer_account.address,amount)print('ETH transfer: ',tx.hex())w3.eth.waitForTransactionReceipt(tx)
传输ERC20
importosimportjsonfromweb3importWeb3frombifrostimportBifrostSIGNER_PK=os.environ.get('SIGNER_PK',"{default-signer-pk}")FACTORY_ADDRESS=os.environ.get('FACTORY_ADDRESS',"{default-factory-address}")RPC_URL=os.environ.get('RPC_URL',"{default-RPC-URL}")BIFROST_FACTORY=os.environ.get('BIFROST_FACTORY',"{bifrost-factory}")ERC20_ADDRESS=os.environ.get('ERC20_ADDRESS','{default-ERC20-address}')w3Provider=Web3.HTTPProvider(RPC_URL)w3=Web3(w3Provider)signer_account=w3.eth.account.privateKeyToAccount(SIGNER_PK)bifrost=Bifrost(BIFROST_FACTORY,signer_account,w3Provider)address_salt=1amount=int(.1*10**18)# Transfer ERC20# address should have more than .1 (amount) ERC20ERC20_abi=json.load(open('path/to/abi/IERC20.json','r'))ERC20=w3.eth.contract(abi=ERC20_abi)call=ERC20.encodeABI('transfer',args=(signer_account.address,amount))tx=bifrost.makeCall(address_salt,ERC20_ADDRESS,0,call)print('ERC20 transfer: ',tx.hex())
注意
以下错误
{'code': -32000, 'message': 'gas required exceeds allowance (7447619) or always failing transaction'}
主要与always failing transaction
通过{str 1}$dtecdeal使用成功