If there is a payment method in the contract, then after deploying the contract using https://www.sway-playground.org/, how to pass in the payment and amount of eth when interacting with the contract?
such contract as:
#[payable]
#[storage(read, write)]
fn buy() {
…
require(AssetId::base() == msg_asset_id(), AssetError::IncorrectAssetSent);
require(
PRICE <= msg_amount(),
AssetError::InsufficientPayment,
);
…
Thank you for your reply, but your reply did not solve my problem. There is no amount parameter in my example. I get the passed amount through msg_amount() in the contract.
When debugging the contract, I found that there is no way to select the input amount. Maybe I need to use the js sdk to debug it separately.
Thanks @william I see my post is at a “tangent” to what you are looking for, and I will be deleting it.
I guess the playground is ideal for getting a “feel” of Sway. Otherwise, to build something beyond the obvious, and do lots of interesting things, then the SDKs are the way to go.
Thanks for ur reply @crypt0mate
Using sdk to debug and add callParams({
forward: [amountToForward, baseAssetId],
}) can be achieved.
This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.