⌘K

Icon SunFilledIcon MoonStars

Icon LinkGenerating bindings with abigen

You might have noticed this snippet in the previous sections:

abigen!(Contract(
    name = "MyContract",
    abi = "packages/fuels/tests/contracts/contract_test/out/debug/contract_test-abi.json"
));

The SDK lets you transform ABI methods of a smart contract, specified as JSON objects (which you can get from Forc Icon Link), into Rust structs and methods that are type-checked at compile time. In order to call your contracts, scripts or predicates, you first need to generate the Rust bindings for them.

The following subsections contain more details about the abigen! syntax and the code generated from it.