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?

Gagan
  • 433
  • 6
  • 17

1 Answers1

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

pabloruiz55
  • 7,686
  • 2
  • 17
  • 38