cairo contract with constructor won't compile

106 Views Asked by At

this the screenshotI have a very simple cairo contract that I want to compile using scarb build but it won't compile, below is my code:

use serde:: Serde;
use starknet:: ContractAddress;
use array:: ArrayTrait;
use option::OptionTrait;

#[derive(Drop, Serde)]
struct Call{
    to: ContractAddress,
    selector: felt252,
    calldata:Array<felt252>,
}

#[account_contract]
mod Account{
    use starknet::get_caller_address;
    use starknet::get_tx_info;
    use starknet:: call_contract_syscall;
    use starknet:: VALIDATED;
    use array:: ArrayTrait;
    use array::SpanTrait;
    use box::BoxTrait;
    use ecdsa :: check_ecdsa_signature;
    use option::OptionTrait;
    use super:: Call;
    use starknet::ContractAddress;
    use zeroable:: Zeroable;
    use serde::ArraySerde;

    struct Storage {
        fam_code: felt252,
    }
   

    #[constructor]
    fn constructor(_fam_key:felt252){
        fam_code::write(_fam_key);
        return();
    }
}

as we don't have much online resource on Cairo, I am hoping to get assistance here

1

There are 1 best solutions below

2
On

I need more information to reproduce the error. Can you share the following please?

  • Which scarb version you are using?
  • What does the error say

Edit: The issue you are facing is that Scarb 0.4.0 uses a new version of the Cairo compiler, in which the way storage is declared and managed is changed. Please check out this post for more information. Happy hacking!