基于盐而不是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使用成功

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java根据一些规则对地图进行排序   java需要关于突破游戏冲突bug的帮助   在Javaservlet中打印XSLT转换的XML文档   使用volatile'status flag'布尔值的java同步?   java Hibernate 4.2、JPA 2.0关系OnetoMany单向注释   在java中,如何在不使用for循环的情况下找到数组列表中第二高的数字?   排序Java多维数组   安装位置上的java Izpack toggel复选框   使用SQL Server 2008数据库交付Java应用程序   处理如何解决线程“动画线程”java中的异常。lang.NullPointerException?   安卓如何在Java中调用OpenSSL方法?   JAVA使用tomcat在jsf应用程序上运行lang.StackOverflowerError   java隐藏javafx Listview中的垂直滚动条   java如何使用Spring Boot在运行时提供静态资源?   java如何将@EJB与远程接口结合使用”   java哪个版本是Sun/Oracle提供的JavaEEAPIX的最新版本。jar和下载最新版本>7.0   java向JavaFX ToggleSwitch添加更改侦听器   保存在哪里以及如何处理Java应用程序的版本?   java AsyncTask执行doInBackground()时出错