Reputation: 929
I'm creating a DApp using Ethereum smart contracts, written in Solidity.
I would like to interact with the contract and pay tokens to the winner of a P2P game. The game could be rock paper scissors for simplicity's sake. A witness would host the game, and send a call to the contract to pay out to the winner.
Say we have two players: player 1
has an Ethereum wallet with public key a1b2c3d4e5
(The winner of the round)
player 2
has a public key of f6g7h8i9j0
(The loser of the round)
How would the witness access the function in my Solidity smart contract that would pay player 1
, from the game-side?
Upvotes: 1
Views: 239
Reputation: 929
You can use the embark framework to build decentralised HTML5 applications that interact with the etherium blockchain.
Embark includes a testing lib to rapidly run & test your contracts in a EVM (Ethereum Virtual Machine).
Embark supports IPFS.
You can create smart contracts such as:
pragma solidity ^0.4.7;
contract SimpleStorage {
uint public storedData;
function SimpleStorage(uint initialValue) {
storedData = initialValue;
}
function set(uint x) {
storedData = x;
}
function get() constant returns (uint retVal) {
return storedData;
}
}
An event may be triggered from the JS framework like this
myContract.eventName({from: web3.eth.accounts}, 'latest')
.then(function(event) { console.log(event) });
Communication over the IPFS connection is like this
//set yourself as the ipfs provider
EmbarkJS.Messages.setProvider('orbit', {server: 'localhost', port: 5001})
EmbarkJS.Messages.sendMessage({topic: "sometopic", data: 'hello world'})
Upvotes: 1