Skip to content

Instantly share code, notes, and snippets.

@ivandru
Created January 4, 2019 16:22
Show Gist options
  • Save ivandru/e6d08f503caf8c59e77857e870e65450 to your computer and use it in GitHub Desktop.
Save ivandru/e6d08f503caf8c59e77857e870e65450 to your computer and use it in GitHub Desktop.
Simple Ether Transfer on Ropsten
import web3
import json
from eth_account import Account
from web3 import Web3
w3 = Web3(Web3.HTTPProvider('https://ropsten.infura.io/v3/apiKey'))
acct = Account.privateKeyToAccount('private key')
nonce = w3.eth.getTransactionCount(acct.address)
transaction = {
'to' : toAccount,
'value': 1,
'gas': 21000,
'gasPrice': w3.eth.gasPrice,
'nonce': nonce,
'chainId': 3
}
key = acct.privateKey
signed = w3.eth.account.signTransaction(transaction, key)
w3.eth.sendRawTransaction(signed.rawTransaction)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment