2

Scenario:

  • Alice Account = 2 ETH
  • Admin Account = 0 ETH
  • Bob Account = 0 ETH

Alice wants to send 1 ETH to Bob using my application. Application will charge 0.01 ETH as it's commission and will be added to total transaction fee

Total Fee = Application Fee (0.01) + Network Fee (gas limit * gas price)

Suppose Network fee is calculated to 0.001008 ETH.

Total payable amount = 1.011008 ETH (1 + 0.01 + 0.001008)

After successful transaction following should be the account details

  • Alice Account = 0.988992 ETH
  • Admin Account = 0.01 ETH
  • Bob Account = 1 ETH

where as 0.001008 ETH will be paid to miners

Query:

Q1. How can I build an application where a funds of a single send transaction can be sent to two different addresses (Bob's address and Admin's address)?

Q2. Is it possible to build such an application without using smart contracts?

1

1 Answer 1

4

An smart contract would need to be involved in the process. It would basically be transferred the funds and send them to different accounts as specified within its logic.

Here's a very quick example I've put together for you:

pragma solidity ^0.4.24;

contract Forwarder {

    address admin;
    uint fee = 10;

    constructor() public {

        admin = msg.sender;
    }

    function splitFunds(address _b) public payable {

        admin.transfer(msg.value * fee / 100);
        _b.transfer(msg.value - (msg.value * fee / 100));
    }
}

enter image description here

1
  • so fee equal 10 means 10 percent? or 1 percent? Jan 21, 2022 at 7:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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