Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when deploying simple Constructor example #274

Open
stranger80 opened this issue Oct 1, 2024 · 4 comments
Open

Error when deploying simple Constructor example #274

stranger80 opened this issue Oct 1, 2024 · 4 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers ODHack Issues are part of the HackODFest and the contributors will be rewarded during the hackathon period
Milestone

Comments

@stranger80
Copy link
Contributor

Compile and declare following contract. Then deploy with any parameters - transaction gets REVERTED.

#[starknet::contract]
pub mod ExampleConstructor {
    use starknet::ContractAddress;
    use starknet::storage::Map;

    #[storage]
    struct Storage {
        names: Map::<ContractAddress, felt252>,
    }

    // The constructor is decorated with a `#[constructor]` attribute.
    // It is not inside an `impl` block.
    #[constructor]
    fn constructor(ref self: ContractState, name: felt252, address: ContractAddress) {
        self.names.write(address, name);
    }
}
@ShantelPeters
Copy link

ShantelPeters commented Oct 1, 2024

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hi @stranger80 please can I be assigned to this issue ?

How I plan on tackling this issue

I will approach this issue by:
Modifying my starknet contract by wrapping the constructor within an impl ExampleConstructor block,updating ref self:ContractStateto &mut self,and adding . unwrap() to handle potential write errors.Then depoly the contract using the Skarknet CLI command

@stranger80 stranger80 added good first issue Good for newcomers bug Something isn't working ODHack Issues are part of the HackODFest and the contributors will be rewarded during the hackathon period labels Oct 1, 2024
@stranger80
Copy link
Contributor Author

I will approach this issue by:
Modifying my starknet contract by wrapping the constructor within an impl ExampleConstructor block,updating ref self:ContractStateto &mut self,and adding . unwrap() to handle potential write errors.Then depoly the contract using the Skarknet > CLI command

No, the issue most likely is within the plugin itself, not with the Cairo code. The code copied above is correct, and the contract should deploy correctly. You may try to deploy it via starkli to verify.

Do you still want to try and tackle this, @ShantelPeters ?

@ShantelPeters
Copy link

I will approach this issue by:
Modifying my starknet contract by wrapping the constructor within an impl ExampleConstructor block,updating ref self:ContractStateto &mut self,and adding . unwrap() to handle potential write errors.Then depoly the contract using the Skarknet > CLI command

No, the issue most likely is within the plugin itself, not with the Cairo code. The code copied above is correct, and the contract should deploy correctly. You may try to deploy it via starkli to verify.

Do you still want to try and tackle this, @ShantelPeters ?

Yes I would want to give it a try.

@stranger80
Copy link
Contributor Author

OK, pls hold short until next week, we're running with investigation which may turn this into a non-issue

@stranger80 stranger80 added this to the v0.4.5 milestone Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers ODHack Issues are part of the HackODFest and the contributors will be rewarded during the hackathon period
Projects
Status: In Progress
Development

No branches or pull requests

3 participants