1

As a disclaimer, I am not a solidity developer, so this question might be a bit naive, but any help would be appreciated.

I want to know if I can use a smart contract to code logic for an ethereum wallet address such that any funds sent to the address are automatically distributed to one or more different addresses (using ethereum from the initial payment to cover gas for the redistributive payments). I am doing this as a way of getting around a limitation of Opensea royalty payments (i.e. royalties can only be paid to one wallet). Heretofore, I have manually sent royalty payments to the various members of my team, but I would like to automate the process in a trustless fashion. Even if I had to approve the transfers, trustless redistribution would be much better than what I'm doing now.

I don't need a detailed explanation, just an answer as to whether or not such a thing is possible and maybe the name of a resource or two I could look into.

Many thanks in advance!

1 Answer 1

0

For anyone who might have a similar question, A kind reddit user gave me an answer. Here it is (credit to u/thePsychonautDad):

You can implement this with a smart contract. When a smart contract receives value, the special function receive is called:

receive() external payable { ... }

You can setup a contract that stores the addresses in an array, then on receive(), you send msg.value/addresses.length to each address in the array.

I wrote a simple version of the contract, so you can build on it:

// SPDX-License-Identifier: MIT pragma solidity 0.8.10;

contract splitter { // To store the list of wallet owners address[] public owners; // Public, but you can set as private if you wish

// An event to known when a payment has been received by this wallet
event paymentReceived(uint256 value, address sender);

// Constructor: Executed once at contract creation
constructor(address[] memory _owners) {
    owners = _owners; // Store the wallet owners (immutable after contract creation)
}

// Triggered when a payment is received:
receive() external payable {
    uint i;
    uint l = owners.length; // How many addresses to pay
    uint256 value = msg.value/l; // How much to send each address
    // Pay each of them
    for (i=0;i<l;i++) {
        payable(owners[i]).transfer(value);
    }
    // Trigger the event
    emit paymentReceived({
        value:  msg.value,
        sender: msg.sender
    });
}
}
2

Your Answer

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

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