Let's say I am paying to someone some assets, and I want those assets to be in his wallet in 10 days and not immediatelly. We agree with these terms on both sides. For target to agree with that, he has to see that transaction is on blockchain(the one that is going to execute my payment to his wallet), to do his service for me. I have to write a smart contract that will put transaction on blockchain and executed in 10 days, so my receiver sees it that he will get his asset in 10 days, but not yet receive it in his wallet. How does blockchain has a transaction on blockchain, and only executes it in 10 days and not now?
3 Answers
You can schedule the transaction using a scheduling service:
However, as you need the other party to be able to see the transaction need to create a contract, put the ether there (so the other party can see that you are doing your part) and require the scheduling service to execute a transaction in your contract that sends the ether to the other party in ten days. This is actually easier than it sounds.
Also if you do not need this to be automatic, you can skip the scheduling service and just add a conditional in your contract so that the other party can take the ether in a particular date and not before.
Disclaimer: I wrote the Aion service.
Hope this helps
-
I don't need automatic, as you said skip scheduling and add conditional in contract is the way– senseiCommented May 10, 2018 at 14:41
How does blockchain has a transaction on blockchain, and only executes it in 10 days and not now?
Not possible.
It's not possible, at least in the way you want. You could set a certain gas price, trying to time the execution of your transaction, hoping it will be executed in 10 days, but good luck.
You have other options.
One of them is that you could temporarily transfer ownership of the assets to a contract, and that only in 10 days from your ownership transfer, he will be able to claim ownership.
contract MiddleMan {
//....variables....
uint256 public transfer_time;
function transfer_ownership(....) {
//...some verifications....
//...some actions...
transfer_time = now;
}
function claim_ownership(....) {
//...some verifications....
require(transfer_time + now >= 10 days);
//some actions...
}
}
It's up to you to do the necessary checks about who can send and who can receive the ownership and so on.
-
So basically i would put my asset to that contracts wallet which will then based on contract execute the transaction? How can my target verify that I didn’t lie and said I transferred assets and you will get them at this date? How can he verify?– senseiCommented May 10, 2018 at 14:01
-
Ethereum is a public ledger, he can check at any time that a transaction was made to transfer assets to the middle-man contract. Commented May 10, 2018 at 15:16
Use Ethereum Alarm Clock which is on mainnet and moved more than 1000 ETH so far. It was created by Piper Merriam from Ethereum Foundation in 2016, and now the project has been rebooted.
It is integrated in MyCrypto, here's tutorial how to call smart contract at a later date (just make sure you fill data field of transaction).