2

Normally, when you compile a solidity file for Web3j, you need a bin and abi file. The command for this is

solc <contract>.sol --bin --abi --optimize -o <output-dir>/

To compile a yul file, you need to do:

solc --strict-assembly <contract>.sol

You can add the option bin but not abi so I have no idea how I would get the abi file. Does somebody know a solution for this?

1 Answer 1

1

you simply cant generate an abi out of a yul file. yul isnt as feature rich as solidity and you cant define an explicit external interface from where you can generate an abi from. you can write down the abi yourself and forward the function selectors to actual yul functions.

2
  • Is there a way to deploy it without the abi file. I'm guessing no because it's the interface for the smart contract. If not, then is there an easy way to write or do I need to learn the logic by myself and hope I don't make any mistakes?
    – retlok
    Commented Apr 20, 2022 at 9:05
  • of course you can deploy a contract without an abi, just the compiled bytecode. but it wont be that easy to interact with it. youll need to write an ABI by hand or you just need to know how to call the functions you want to. you need to decode the data sent to the contract manually and call the corresponding function. for better understanding have a look at the following example: docs.soliditylang.org/en/latest/yul.html#complete-erc20-example the most important part is where the function selector is extracted out of the calldata (the switch case at the beginning)
    – davidhass
    Commented Apr 20, 2022 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.