forked from primasio/pst-batch-transfer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
transfer.py
31 lines (22 loc) · 889 Bytes
/
transfer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from __future__ import unicode_literals
from web3 import Web3, HTTPProvider
from test import config
web3 = Web3(HTTPProvider(config.eth_rpc))
web3.eth.defaultAccount = config.account_address
from web3 import personal as wp
p = wp.Personal(web3)
print("isConnected:", web3.isConnected())
print("unlockAccount: ", p.unlockAccount(web3.eth.defaultAccount, config.passwd)) # ropsten
token_Contract = web3.eth.contract(
abi=config.TOKEN_ABI
)
t_contract = token_Contract(address=config.token_contract_address)
def transfer_pst(rows):
for row in rows:
p.unlockAccount(web3.eth.defaultAccount, config.passwd, duration=hex(100))
t = t_contract.transact().transfer(row["address"], int(row["value"]) * 10 ** 18)
print("transfer:", row["address"], row["value"], t)
yield {
"account_address": row["address"],
"tx": t
}