As blockchain networks only take into consideration what is happening in the chain, probably you should connect your private network to your erc20 tokens through oracles. Therefore, depending on what is going on with your smart contracts you can trigger actions on your private network or the oposite.
Following this link you can test how to build an oracle, it is quite straight forward:
https://medium.com/@mustwin/building-an-oracle-for-an-ethereum-contract-6096d3e39551
But also you could use the service oraclize
http://www.oraclize.it
When watching for events from web3, this is the format of the result you get when one is called:
{ address: '0x9c0ac1e0f0a8e0b01c7b652d5fbe094ddff48b81',
blockNumber: 704227,
transactionHash: '0x5887ba4e15d51e1cfddf626ecf416a0002085a1e0929fffe1f90ad69d5040081',
transactionIndex: 0,
blockHash: '0x5f485133ec662f556d88affccc18a358375de160178c6cf7cc0cec678d833a2a',
logIndex: 0,
removed: false,
event: 'ExampleEvent',
args:
{ argOne: BigNumber { s: 1, e: 0, c: [Array] },
argTwo: '0x374623456fa2' } }
So you can just get the TX from result.transactionHash
Event in contract:
event ExampleEvent(uint argOne, bytes32 argTwo)
Web3 code:
import exampleContractObject from 'path/to/ExampleContract.json'
ExampleContract = web3.eth.contract(exampleContractObject.abi);
contractInstance = ExampleContract.at('0x9c0ac1e0f0a8e0b01c7b652d5fbe094ddff48b81');
exampleEvent = contractInstance.ExampleEvent();
exampleEvent.watch((err, result) => {
// Do something
}
EDIT:
The Transfer event from ERC20 tokens would look like this:
{ address: '<contract_address>',
blockNumber: <block_number>,
transactionHash: '<transaction_hash>',
transactionIndex: <tx_index_in_block,
blockHash: '<block_hash>',
logIndex: <log_index>,
removed: <> ,
event: 'Transfer',
args:
{ _from: <address>,
_two: <address> ,
_value: <uint256>} }
Best Answer
You cannot do this with fewer than 2 clicks, but you can do it with 2.
If your trading platform is a web site, and users are using (or can be persuaded to use) MetaMask (or similar, such as Mist, Toshi, Parity Browser or SpaceSuit), then you can request a payment from within the trading platform, using a JavaScript library (such as Web3, or truffle-contract, or EthJS) to call
transfer
on the ERC20 token. They would click "Buy" on your site, then the plugin would ask them to confirm the amount and transaction details.If your users would like future payments to be automated, ERC20 contracts have an
approve
method, that can be used approve an address to make future withdrawals (which can be limited to a certain amount), so the user would not need to take any further action after the initial approval.