So I am trying to transfer a FT, saved as a file ft.rs
, which is generated in the standard way, like so:
impl Contract {
/// Initializes the contract with the given total supply owned by the given `owner_id` with
/// default metadata (for example purposes only).
#[init]
pub fn new_default_meta(owner_id: AccountId, total_supply: U128) -> Self {
Self::new(
owner_id,
total_supply,
FungibleTokenMetadata {
spec: FT_METADATA_SPEC.to_string(),
name: "Example NEAR fungible token".to_string(),
symbol: "EXAMPLE".to_string(),
icon: None,
reference: None,
reference_hash: None,
decimals: 24,
},
)
}
/// Initializes the contract with the given total supply owned by the given `owner_id` with
/// the given fungible token metadata.
#[init]
pub fn new(
owner_id: AccountId,
total_supply: U128,
metadata: FungibleTokenMetadata,
) -> Self {
assert!(!env::state_exists(), "Already initialized");
metadata.assert_valid();
let mut this = Self {
token: FungibleToken::new(b"a".to_vec()),
metadata: LazyOption::new(b"m".to_vec(), Some(&metadata)),
};
this.token.internal_register_account(&owner_id);
this.token.internal_deposit(&owner_id, total_supply.into());
near_contract_standards::fungible_token::events::FtMint {
owner_id: &owner_id,
amount: &total_supply,
memo: Some("Initial tokens supply is minted"),
}
.emit();
this
}
}
And I want to make another contract which can do two things, send the ft, and receive an ft:
pub use crate::ft::*;
mod ft;
impl Contract {
#[payable]
fn receive_ft(&self) -> bool {
// user sends ft and this contract registers and stores it
}
#[payable]
fn send_ft(&self, receiver : AccountId, amount : U128) -> bool {
// user sends ft to external address
}
}
Anyone here to point me in the right direction?