Skip to content

ABI Typegen

The JSON ABI file

Whether you want to deploy or connect to a pre-existing smart contract, the JSON ABI file is what makes it possible.

It tells the SDK about the ABI methods in your Smart Contracts and Scripts

Given the following Sway smart contract:

rust
contract;

abi MyContract {
    fn test_function() -> bool;
}

impl MyContract for Contract {
    fn test_function() -> bool {
        true
    }
}

The JSON ABI file would look something like this:

json
$ cat out/debug/my-test-abi.json
[
  {
    "type": "function",
    "inputs": [],
    "name": "test_function",
    "outputs": [
      {
        "name": "",
        "type": "bool",
        "components": null
      }
    ]
  }
]

See also: