44 points · by bleumi · 8y ago · 13 comments
from web3 import Web3, HTTPProvider
web3 = Web3(HTTPProvider('http://localhost:8545')) #Assuming you're running your own ETH node
your_eth_wallet_address = web3.eth.accounts[0] #Assuming you want to use your node's first wallet
web3.eth.defaultAccount = your_eth_wallet_address
dapp_contract = web3.eth.contract(contract_address)
#Read data from the dapp or execute a function locally (No transaction cost):
dapp_contract.call().function_name(*function_arguments)
#Send an ETH transaction (Pay for gas, plus whatever this transaction does):
dapp_contract.transact().function_name(*function_arguments)Additionally, all these web3 providers who are developing browser based solutions are trying to provide a psuedo app store to make their platforms more useful.
Some examples I've been playing with lately are:
https://www.cipherbrowser.com/
A competitor in this space is blockstack who is pushing the dApp model hard: https://blockstack.org
For instance, here is a demo of a social network dApp I built that is running a distributed correctness test across many real world devices that are updating character-by-character in realtime: https://youtu.be/C3akdQJs55E (fully P2P and encrypted!)
I know blockstack has been pushing this but they still require their own browser. Meanwhile you can build apps like above as easily as 40 lines of code and a few minutes, check out this interactive coding tutorial: https://scrimba.com/c/c2gBgt4