Converting felt252 to ContractAddress in Cairo

308 views Asked by At

How do I create a ContractAddress from a hex value like 0x06D98dC7ea54CF77eeD141F423f6007Dd61fbd2b6bD429Facdf5d4803353063f?

let addr : ContractAddress = 0x06D98dC7ea54CF77eeD141F423f6007Dd61fbd2b6bD429Facdf5d4803353063f; is throwing an exception stating that 0x06D98dC7ea54CF77eeD141F423f6007Dd61fbd2b6bD429Facdf5d4803353063f is considered a felt252.

What's the helper function to convert that Hex into a ContractAddress?

1

There are 1 answers

1
Manmit Singh On

This is the library file for that: https://github.com/starkware-libs/cairo/blob/main/corelib/src/starknet/contract_address.cairo

I believe the function Felt252TryIntoContractAddress would be useful.