Skip to content

Instantly share code, notes, and snippets.

@mayeaux
Forked from ivandru/send.py
Created August 31, 2019 03:45
Show Gist options
  • Save mayeaux/10c5939be79f2f90695bde5c08300859 to your computer and use it in GitHub Desktop.
Save mayeaux/10c5939be79f2f90695bde5c08300859 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