logoAcademy

Interact with a Precompile

Learn about why you should utilize Precompiles in your smart contracts.

So let's get to it and interact with a precompile on the C-Chain of your local network.

Call Precompile from Foundry

In this example, we will call the SHA256 precompile to generate hash of the input string.

Precompile Address: 0x0000000000000000000000000000000000000002

cast call --rpc-url local-c --private-key $PK 0x0000000000000000000000000000000000000002 "run(string)(bytes32)" "test"

You should see a bytes32 hash of the input string test as the output.

On this page