You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The user is currently working on setting up a transaction that utilizes a custom payment code rather than the standard one. However, the user encounters an error: HandlePayment error: Unable to remove named key.
The user is running their tests via NCTL using the v2-rc5 docker image provided by MAKE.
Below is the payment code I'm using for reference:
use casper_contract::{
contract_api::{account, runtime, system},
unwrap_or_revert::UnwrapOrRevert,
};
use casper_types::{
runtime_args, system::handle_payment, ApiError, Phase, RuntimeArgs, URef, U512,
};
const ARG_AMOUNT: &str = "amount";
#[repr(u16)]
enum Error {
InvalidPhase,
}
impl From<Error> for ApiError {
fn from(e: Error) -> Self {
ApiError::User(e as u16)
}
}
fn get_payment_purse() -> URef {
runtime::call_contract(
system::get_handle_payment(),
handle_payment::METHOD_GET_PAYMENT_PURSE,
RuntimeArgs::default(),
)
}
fn set_refund_purse(new_refund_purse: URef) {
let args = runtime_args! {
handle_payment::ARG_PURSE => new_refund_purse,
};
runtime::call_contract(
system::get_handle_payment(),
handle_payment::METHOD_SET_REFUND_PURSE,
args,
)
}
#[no_mangle]
pub extern "C" fn call() {
if runtime::get_phase() != Phase::Payment {
runtime::revert(Error::InvalidPhase);
}
let amount: U512 = runtime::get_named_arg(ARG_AMOUNT);
let payment_purse = get_payment_purse();
set_refund_purse(account::get_main_purse());
// transfer amount from named purse to payment purse, which will be used to pay for execution
system::transfer_from_purse_to_purse(account::get_main_purse(), payment_purse, amount, None)
.unwrap_or_revert();
}
Date Issue Began(optional)
No response
Attachments (optional)
No response
The text was updated successfully, but these errors were encountered:
Category
Bug/Issue
Your email address
[email protected]
Integration Project Name(Optional)
No response
Casper Network
Devnet
Node Functionality
Node
Description
The user is currently working on setting up a transaction that utilizes a custom payment code rather than the standard one. However, the user encounters an error: HandlePayment error: Unable to remove named key.
The user is running their tests via NCTL using the v2-rc5 docker image provided by MAKE.
Below is the payment code I'm using for reference:
Date Issue Began(optional)
No response
Attachments (optional)
No response
The text was updated successfully, but these errors were encountered: