I've created an Ethereum token that could be transfered from user to user.
As a next step I would like to write a smart contract that transfers an amount of tokens from user A to user B when a specific state has been reached.

Example:

User A has 10 tokens.

User B has 1 token.

Third party company registers actions of the users on their website / app

All users trust a third party company.

User A agreed with the 3rd party that it is allowed to transfer 1 token to user B when condition 1 is met. For example if user B clicks 100x times on a specific button.
Interaction between User B and the third party company should trigger the transfer. User A allows the 3rd party to transfer tokens.

How can I put such logic in a smart contract?
I've found smart contract examples online where a smart contract is linked to another smart contract (3rd party) which tells if the condition is met or not. This does mean that all the clicks need to be registered on the blockchain?
The condition will be different for each other user, for example a different interaction or different number of tokens.

1 Answer
1

If the third party is "trusted", then the approve and transferFrom functions from the ERC-20 standard should work just fine here.

User A would approve for the trusted third party to spend some amount of tokens.

Then, the trusted third party would simply call transferFrom(UserA, UserB, Amount) when they wanted to send tokens from User A to User B. It would be up to the third party to determine when to call this function, so you can do any off-chain or on-chain requirement to trigger that action.

If you want to keep even more logic and checks on the blockchain, then you might need to elaborate on how exactly you want to trigger these transfers.