0

I have a smart contract which contains a function called "withdraw" - which basically increases a users balance by X amount of an ERC20 token. The user can decide how much to withdraw by passing a variable "amount" to the function. However, a centralised app must check to ensure that the user can "withdraw" this amount. I was hoping that the user could basically sign a transaction that they wish to "withdraw" X tokens, pass this signature to the server which would then run the check and execute the function. This way the user pays the gas fees but the server can ensure they are permitted to execute the function. Is this flow possible? Ideally without using an oracle like Chainlink

2 Answers 2

1

This sounds like an effort to revise the business rules after the contract has been deployed. You'll find that difficult or impossible.

It would be possible to send a signed txn to a server, but it won't be possible to ensure that users do so when they can go directly to the contract. You can't rely on users using a certain UI or backend to enforce business rules or security principles.

It would be possible to write the contract in such a way that only the server is allowed to interact with the contract and the server is trusted with determining which user each transaction is concerned with, possibly by inspecting a signature. That would re-introduce centralization and a single point of failure which might not be an acceptable design decision. In any case, it can't be done to an already deployed contract that works another way.

Hope it helps.

0

I don't think that is possible--whoever is executing the transaction will pay the gas fees. You can use a merkle tree or something similar to distribute rewards to all users using only one transaction, allowing them to claim them themselves.

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.