contract development - How to quickly test a Solidity function? - Ethereum Stack Exchange

Tags
URLhttps://ethereum.stackexchange.com/questions/2835/how-to-quickly-test-a-solidity-function

One way is to use Remix, the browser-based Solidity realtime compiler and runtime Solidity (formerly named browser-solidity).

  1. Paste the code in Remix.
  1. Wrap the function inside a contract if needed. (Example: contract C { ... }.)
  1. Click Contract tab and then Create to instantiate the contract.
  1. Enter the desired input next to the function.
    • For bytes1 ... bytes32, use a quoted hex string, example "0xabcdef" for bytes3.
    • For strings, make sure they are quoted.
    • For an array, use [], example: ["hello", 42, "0xabcd"]
  1. Click the function to get the Result. The Result is ABI encoded.

Here is an example screenshot: