AndreMiras / EtherollApp

Provably fair dice game running on the Ethereum blockchain
MIT License
57 stars 22 forks source link

Place a bet on the testnet #1

Closed AndreMiras closed 6 years ago

AndreMiras commented 6 years ago

Deploy the contract on the testnet, try to place a bet and document the instructions

AndreMiras commented 6 years ago

Since we don't run a node locally and since ropsten.infura.io and api.myetherapi.com obviously don't provide access to account management, we'll need to deal with a local file accounts and manage transaction signing manually, see https://github.com/ethereum/web3.py/blob/v4.0.0-beta.11/docs/contracts.rst and https://github.com/ethereum/web3.py/blob/v4.0.0-beta.11/docs/web3.eth.account.rst I believe the strategy would be:

  1. prepare the transaction with web3
  2. retrieve unlock the local account from ~/.ethereum/keystore/ and extracting private key
  3. update the transaction with the signature and broadcast it from web3

Pseudo code could be:

transaction = etheroll.contract.functions.playerRollDice(roll_under).buildTransaction()
encrypted_key = open('~/.ethereum/keystore/wallet.json').read()
private_key = w3.eth.account.decrypt(encrypted_key, password)
signed = w3.eth.account.signTransaction(transaction, private_key)
w3.eth.sendRawTransaction(signed_transaction.rawTransaction)
AndreMiras commented 6 years ago

Bet placed on Testnet from local wallet account. From the current code, simply update password, wallet_path and from_address_normalized.