0

I'm trying create a smart contract that allows customers to refund there ethereums if the pre-order of the token is unsuccessful.

Is it possible to create a function in the contract to be used by the investors for refunding, so that the gas is for the refund transaction is payed by the investors. And if so how can one achieve that.

The main goal is to have a refund build into the smart contract but to avoid the creator of the ICO to pay a lot of fees for refunding.

2

It is best practice to require users to withdraw funds from a contract rather than pushing funds to them yourself.

This means users will pay for all transaction costs related to withdrawal. As shown in the link I provided above, a function such as the one below would suffice for this purpose. Users should call this function from their own accounts rather than you initiating the refund.

function withdrawRefund() external {
    uint refund = refunds[msg.sender];
    refunds[msg.sender] = 0;
    msg.sender.transfer(refund);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.