0

Why do we write "abi" before abi.encode()? I understand that ABI is a like a JSON file used to help interaction of different applications because the solidity code is stored as bytecode, but I don't understand why we write "abi" before some "specific" functions in solidity.

I also know that abi.decode is a specific decoding function but why do we add "abi" before it. What is its usecase? https://solidity.readthedocs.io/en/v0.5.3/units-and-global-variables.html#abi-encoding-and-decoding-functions

1 Answer 1

1

I'm guessing you mean: "Why do we have to put 'abi' into 'abi.encode()'?"

ABI encoding functions were added in Solidity 0.4.24 as a new feature.

Typing 'abi' before specific functions is intended as a way to easily identify those functions which deal with ABI encoding. It's just a design choice that the Solidity team made.

1
  • Thanks! I am coming from Java background and something with a '.' usually meant a package or class so I got confused. Thanks alot! Aug 26, 2020 at 7:23

Your Answer

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

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