I need help with that code. Can anyone pls help me out ??

mod p{
        pub struct Foobar {
            /// Stores a single `bool` value on the storage.
            value: bool,

        impl Foobar {
            pub fn default() -> Self {

        async fn default_works(mut client: ink_e2e::Client<C, E>) -> E2EResult<()> {
            // Given
            let constructor = FoobarRef::default();

what this line actually means. I have not created anything with the name FoobarRef but we are using it. and if FoobarRef is the same as Foobbar what is stored in a variable named constructor and how can I print it? let constructor = FoobarRef::default();

1 Answer 1


That FoobarRef is generated by ink! is a reference of the contract, it gives you the information about available methods (args, return types) of the contract you want to call.

With that line you can create an instance of your contract and interact with it in your test:

let contract_acc_id = client
                .instantiate("your_contract", &ink_e2e::alice(), **constructor**, 0, None)
                .expect("instantiate failed")

See this example in the ink/examples repository and the Flipper example from the ink! Documentation

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.