I have a faucet token contract named "faucet.xxx.testnet" and there is a minting method where I would mint some tokens to my near wallet "m2.testnet" account and do a call back at the same time in the contract. However, after calling to the minting method from m2.testnet, I always get the msg "that account faucet.xx.testnet is not registered". I don't understand what is wrong with this contract.
#[ext_contract(ext_ft_contract)]
pub trait FungibleTokenCore {
fn ft_transfer(&mut self, receiver_id: AccountId, amount: U128, memo: Option<String>);
}
pub fn faucet_token(&mut self, amount: U128) -> Promise {
let account_id: AccountId = env::predecessor_account_id();
ext_ft_contract::ft_transfer(
account_id.clone(),
amount,
Some(String::from("Faucet by MD Dev")),
&self.ft_contract_id,
1,
FT_TRANSFER_GAS
)
.then(ext_self::ft_transfer_callback(
amount,
account_id.clone(),
&env::current_account_id(),
0,
FAUCET_CALLBACK_GAS
))
#[private]
pub fn ft_transfer_callback(&mut self, amount: U128, account_id: AccountId) {
let mut account_balance: Balance = self.accounts.get(&account_id).unwrap_or_else(|| 0);
if account_balance == 0 {
self.total_account_shared += 1;
}
account_balance += amount.0;
self.accounts.insert(&account_id,&account_balance);
self.total_shared += amount.0;
if self.total_balance_share > amount.0 {
self.total_balance_share -= amount.0;
}
}
Scheduling a call: faucet.xx.testnet.faucet_token({"amount":"1000000000"})
Doing account.functionCall()
Receipts: 5aHoX36TLbgpUhkLibCRB7uaNsy79go2ZY86QbC4WnFK, 2MFeD2yJB7yQ7DPKuoZSk3fbUNH3XpPUiAazhWZoa3Do
Failure [faucet.xx.testnet]: Error: {"index":0,"kind":{"ExecutionError":"Smart contract panicked: The account faucet.xx.testnet is not registered"}}
You must deposit money into the contract for both sending and receiving accounts to register to be able to transfer token. Use command:
Example See more at: NEP141