简体   繁体   中英

Solidity inline-assembly: Calling other functions within one contract and using interfaces

i am currently running into the issue that I can't call an outside function within my smart contract.

So for example, I have my function f() including the inline assembly code from which I want to call the function g() which is also within the smart contract.

Is this even possible? And if yes, is it also possible to use interfaces within assembly?

Thank you for your time.

No, it is currently not possible to call Solidity functions from inline assembly. You can only call Yul functions declared within the same assembly block. There are plans to allow calling functions defined in other assembly blocks but these would still be Yul functions and not Solidity functions.

As for interfaces, from the perspective of inline assembly an interface is just an address. You can do low-level calls from assembly blocks so technically you can use an interface but this is no different than just using an address variable and you do not get any of the high-level syntax you have at the Solidity level. For example you have to manually encode the function selector and the arguments and then process the result.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM