Solidity contract to charge a % fee from the transaction value
Budget: €100 – €300 EUR
I'm currently working on a web3 automation software which can be used to automate NFT mints, token swaps and any kind of Ethereum transaction.
Instead of charging our users a monthly price, we want to charge our users based on a transaction fee.
Each time a user uses our software to send a transaction they will be charged a % of the total value if the transaction is successful.
We want a solidity contract which has a method that takes as parameters the target contract to call and the input data which will include the encoded method data to call from the target contract, this way, our custom contract will call the external contract with the provided data, check if the call is successful, and take a % of the total value and send it to our vault.
Keep in mind the transaction sent from our software will be sent with the necessary value for the external contract call + the % fee, so the call to the external contract must be done with the correct value (msg.value - fee).
We have tried using delegatecall so the nft minted is sent to the user which sent the transaction and not our contract, while taking the fee before making the call, but the delegatecall is still being done with the msg.value which includes the fee and it fails as it missmatches the input data which has an enconded value of msg.value - fee.
We dont really know if it's possible to achieve this on a same transaction and contract call but it would be the most optimal thing to do.
Example: Lets say a user wants to mint an NFT which costs 1ETH, our software will send a transaction to our custom contract with the NFT contract address, the mint method data and a value of 1.001 ETH (1ETH + 1%). then the contract should extract the 1% and send it to our vault while making the call with the remaining value.
As said before we dont know if this is possible and it doesn't have to be done this way, we are open to other methods but we would like to keep it low level via contracts and 1 transaction only.
Requirements:
- Experience in Solidity and smart contract development on the Ethereum platform
- Familiarity with blockchain concepts and Ethereum ecosystem
Timeline:
- The project should be completed within a week.
Instead of charging our users a monthly price, we want to charge our users based on a transaction fee.
Each time a user uses our software to send a transaction they will be charged a % of the total value if the transaction is successful.
We want a solidity contract which has a method that takes as parameters the target contract to call and the input data which will include the encoded method data to call from the target contract, this way, our custom contract will call the external contract with the provided data, check if the call is successful, and take a % of the total value and send it to our vault.
Keep in mind the transaction sent from our software will be sent with the necessary value for the external contract call + the % fee, so the call to the external contract must be done with the correct value (msg.value - fee).
We have tried using delegatecall so the nft minted is sent to the user which sent the transaction and not our contract, while taking the fee before making the call, but the delegatecall is still being done with the msg.value which includes the fee and it fails as it missmatches the input data which has an enconded value of msg.value - fee.
We dont really know if it's possible to achieve this on a same transaction and contract call but it would be the most optimal thing to do.
Example: Lets say a user wants to mint an NFT which costs 1ETH, our software will send a transaction to our custom contract with the NFT contract address, the mint method data and a value of 1.001 ETH (1ETH + 1%). then the contract should extract the 1% and send it to our vault while making the call with the remaining value.
As said before we dont know if this is possible and it doesn't have to be done this way, we are open to other methods but we would like to keep it low level via contracts and 1 transaction only.
Requirements:
- Experience in Solidity and smart contract development on the Ethereum platform
- Familiarity with blockchain concepts and Ethereum ecosystem
Timeline:
- The project should be completed within a week.