web3
// Fetch all TRANSACTIONS of user
const purchase = async () => { const web3 = window.web3; const contract = new web3.eth.Contract(ABI, CONTRACT_ADDRESS); const allTransactions = await contract.methods.transactionsOfWalletOwner().call();
console.
// Buy with BNB or some other asset
const purchase = async () => {
const web3 = window.web3; // Create instance of Web3
const contract = new web3.eth.Contract(ABI, CONTRACT_ADDRESS); // Create contract config
const gasPrice = await web3.eth.getGasPrice(); // Get gas price
const price = await contract.methods.getBnbPrice().call(); // Reetrieve Token/NFT price from contract
// Missing many validation process TODO
// Begin purchase transaction
const purchase = await contract.methods.purchase().send({
from: account,
gas: 200000,
value: price,
gasPrice: gasPrice
});
console.log(purchase);
}
// Buy with TOKEN
const purchase = async () => {
const web3 = window.web3;
const contract = new web3.eth.Contract(ABI, CONTRACT_ADDRESS);
const gasPrice = await web3.eth.getGasPrice();
const price = await contract.methods.getTokenPrice().call();
const purchase = await contract.methods.purchaseWithToken(price).send({
from: account,
gas: 200000,
value: price,
gasPrice: gasPrice
});
console.log(purchase);
}
// Retrieve quantity of user tokens
const purchase = async () => {
const web3 = window.web3;
const contract = new web3.eth.Contract(ABI, CONTRACT_ADDRESS);
const countPioneer = await contract.methods.pioneerCount().call();
console.log(countPioneer);
}
// Fetch all TOKENS/NFTs of user
const purchase = async () => {
const web3 = window.web3;
const contract = new web3.eth.Contract(ABI, CONTRACT_ADDRESS);
const allTokens = await contract.methods.tokensOfWalletOwner().call();
console.log(allTokens);
}