CRYPTO NEWS

Roole Locates Stolen Vehicles Globally via Nodle Network’s On-Chain Services

San Francisco, United States / California, 20th September, 2022, Chainwire If a Roole vehicle is reported stolen, millions of Nodle-enabled smartphones will work together to find the lost […]

Redirecting to different functions dynamically in smart contract

I would like to have an external function that decodes a signature, and after that, redirects to necessary function with its parameters. It should look something like this: address owner; function redirect(bytes signature) external { // decode the signature with owner address, and get functionName and its parameters // redirect to functionName with parameters (a::Listen

I would like to have an external function that decodes a signature, and after that, redirects to necessary function with its parameters. It should look something like this:

address owner; function redirect(bytes signature) external {   // decode the signature with owner address, and get functionName and its parameters   // redirect to functionName with parameters (a or b or c) }  function a() internal {} function b(uint256) internal {} function c(string, bytes32) internal {} 

The reason I want this functionality is, I want to be able to execute functions in the smart contract I provided to the customer (or owner) from my own address as well as directly from his address, but I want to be able to do it only if the customer signed the message, and the message contains functionName and parameters and a nonce as well so it is obvious that this signature can’t be replicated. So my questions are these:

1_ How should I sign the parameters while sending the transaction (I am using ethers.js) and how can I decode them efficiently from the smart contract?

2_ How can I redirect to the needed function dynamically with its parameters (without using if statements, maybe something like a low level call)?

3_ How can I manage the nonce efficiently? I thought of counting the nonce up in the contract and checking it, but I might have to send multiple transactions from different web clients, which might cause race condition.

Roole Locates Stolen Vehicles Globally via Nodle Network’s On-Chain Services

Shopping cart
There are no products in the cart!
Continue shopping
0