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

rusk-wallet: Implement http contract query #3169

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

Daksh14
Copy link
Contributor

@Daksh14 Daksh14 commented Dec 12, 2024

Closes #3108

Deploy my_first_contract.wasm Copy the generated contract_id and then contract call increment function 4 times

> Contract call transaction hash: 128b39f5ef8da2e1ddaacccebab29b176d51181e369e29c50ba1bc694cc34752
> Http contract query: <empty>

Then call read_value

> Introduce string for function name to call: read_value
> Introduce hex bytes for arguments of calling function:
> Introduce the gas limit for this transaction: 2000000000
> Introduce the gas price for this transaction: 1 LUX
> Contract call transaction hash: c49d238afa74a563fe8f73167a94f42a5f8b1cea526e9e753f294c45cb1c1a1e
> Http contract query: 4

Only supports u32 return values

@Daksh14 Daksh14 force-pushed the contract_query branch 2 times, most recently from 4d1b160 to 689d386 Compare December 12, 2024 01:31
rusk-wallet/src/wallet.rs Outdated Show resolved Hide resolved
@herr-seppia
Copy link
Member

Why do you request gas price for contract query?
Why there is a transaction has for those query?

Copy link
Contributor

@miloszm miloszm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return value from http_contract_call should be Option<Vec<u8>> IMO

rusk-wallet/src/wallet.rs Outdated Show resolved Hide resolved
@herr-seppia
Copy link
Member

Just to be clear

There is NO need to create a transaction to to query a contract, so I don't get which tx_hash this snippet refers to

                let http_call = wallet
                    .http_contract_call(contract_id, &fn_name, &fn_args)
                    .await?;

                Ok(RunResult::ContractCall(tx.hash(), http_call))

@Daksh14
Copy link
Contributor Author

Daksh14 commented Dec 12, 2024

@herr-seppia The http contract call is done alongside already existing tx contract call so if you do contract call it will send both the transaction and the http request to return values

@herr-seppia
Copy link
Member

What's the need for sending both?

@Daksh14
Copy link
Contributor Author

Daksh14 commented Dec 12, 2024

@herr-seppia I combined them because if you wanna call increment you need to do tx contract call but if you wanna call read_value you need to do http contract call.

If you want I can separate them that might save gas fees but the user might be confused

let hash = hex::encode(scalar.to_bytes());
writeln!(f, "> Contract call transaction hash: {hash}",)?;

writeln!(f, "> Http contract query: {:?}", bytes)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will give really ugly output, use hex::encode(bytes)

@herr-seppia
Copy link
Member

Don't mix the transactions and the queries pls

About "save fees", there is no fee to save, since the query is free

@Daksh14
Copy link
Contributor Author

Daksh14 commented Dec 12, 2024

@herr-seppia Just so you know I'm aware the query is just an http request it not a transaction and there's no fees involved, I said fees because we might wanna do http call and not transaction contract call so that might save fees but I'll seperate both of them now I thought it made senese to do both of them together

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rusk-wallet: Provide both query and transaction contract call
3 participants