PyCon.LT 2018
Jaro Šatkevič - @chompomonim
Full node
Mining
Wallet
Bitcoin core
> from cryptos import *
> c = Bitcoin(testnet=True)
> priv = sha256('a big long brainwallet password')
> priv
'89d8d898b95addf569b458fbbd25620e9c9b19c9f730d5d60102abbabcb72678'
> pub = c.privtopub(priv)
> pub
'041f763d81010db8ba3026fef4ac3dc1ad7ccc2543148041c61a
29e883ee4499dc724ab2737afd66e4aacdc0e4f48550cd783c1a73
edb3dbd0750e1bd0cb03764f'
> addr = c.pubtoaddr(pub)
> addr
'mwJUQbdhamwemrsR17oy7z9upFh4JtNxm1'
It knows only what it was told about
Online
Service
User
Service
beneficiary: public(address)
auction_start: public(timestamp)
auction_end: public(timestamp)
highest_bidder: public(address)
highest_bid: public(wei_value)
ended: public(bool)
@public
def __init__(_beneficiary: address, _bidding_time: timedelta):
self.beneficiary = _beneficiary
self.auction_start = block.timestamp
self.auction_end = self.auction_start + _bidding_time
@public
@payable
def bid():
assert block.timestamp < self.auction_end
assert msg.value > self.highest_bid
if not self.highest_bid == 0:
send(self.highest_bidder,self.highest_bid)
self.highest_bidder = msg.sender
self.highest_bid = msg.value
@public
def end_auction():
assert block.timestamp >= self.auction_end
self.ended = True
send(self.beneficiary, self.highest_bid)
import json
import web3
from web3 import Web3, TestRPCProvider
from solc import compile_source
from web3.contract import ConciseContract
w3 = Web3(TestRPCProvider())
contract = w3.eth.contract(abi=abi)
contract_address = '0x85aC27E4124863492DB18EAFBb358102Cad8fc96'
contract_instance = w3.eth.contract(
abi=abi,
address=contract_address,
ContractFactoryClass=ConciseContract)
contract_instance.bid(transact={'from': w3.eth.accounts[0], 'value': 10000})
print('Highest bid: {}'.format(contract_instance.highest_bid()))
Jaro Šatkevič - @chompomonim - me@jarocoin.com