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

Add injection of asset amount (call parameter) into wallet within playground contract interface. #14

Open
CatspersCoffee opened this issue Jul 5, 2023 · 0 comments

Comments

@CatspersCoffee
Copy link

Problem Description:

Using the contract interface to send an amount of some asset (in this case BASE_ASSET_ID) via the contract interface call does not seem to have the ability to inject or add an amount (to send in to a contract via call params) via the wallet.

i.e., The below function in Sway has the ability to accept within the call parameters a amount of BASE_ASSET_ID :

    #[storage(read, write)]
    fn receive_funds() {
        if msg_asset_id() == BASE_ASSET_ID {
            storage.balance += msg_amount();
        }
    }

Using fuels-rs this is done with a simple example:

    let contract_instance = MyContract::new(_contract_id.into(), wallet.clone());

    let tx_params = TxParameters::default()
        .set_gas_price(1)
        .set_gas_limit(1_000_000)
        .set_maturity(0);

    let deposit_amount = 1_000_003;

    let call_params = CallParameters::default()
        .set_amount(deposit_amount)
        .set_asset_id(BASE_ASSET_ID);

    let res = contract_instance
        .methods()
        .receive_funds()
        .tx_params(tx_params)
        .call_params(call_params).unwrap()
        .call()
        .await;

However, when using sway-playground, there is no way for the user making the call to this function (receive_funds()) via the contract interface and add an "amount" to the transaction that is being signed.

waltx
interface_rec_fun

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

No branches or pull requests

3 participants