We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
use near_sdk::{env, near_bindgen, ext_contract, Promise}; use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize}; use near_sdk::collections::Vector; #[ext_contract(ext_erc20)] trait ExtERC20 { fn transfer(&mut self, receiver_id: AccountId, amount: u128) -> Promise; fn approve(&mut self, spender_id: AccountId, amount: u128) -> Promise; fn transfer_from(&mut self, owner_id: AccountId, new_owner_id: AccountId, amount: u128) -> Promise; } #[near_bindgen] #[derive(Default, BorshDeserialize, BorshSerialize)] struct Flashloan { erc20_contract: AccountId, amount: u128, data: String, } #[near_bindgen] impl Flashloan { pub fn flashloan(&mut self, amount: u128, data: String) -> Promise { self.amount = amount; self.data = data; ext_erc20::approve(self.erc20_contract.clone(), amount); ext_erc20::transfer(self.erc20_contract.clone(), amount); ext_erc20::transfer_from(env::predecessor_account_id(), self.erc20_contract.clone(), amount); Promise::new(env::predecessor_account_id()).then(ext_erc20::transfer_from( self.erc20_contract.clone(), env::predecessor_account_id(), amount, 1, &env::current_account_id(), 0, env::prepaid_gas() - 10, )) } }
The text was updated successfully, but these errors were encountered:
elicharlese
No branches or pull requests
The text was updated successfully, but these errors were encountered: