if (window.ethereum) {
const ethereum = window.ethereum;
const web3 = new Web3(ethereum);
const ethereum_account = ethereum.request({ method: 'eth_requestAccounts' });
const ct = new web3.eth.Contract(abi, contract);
try {
await ethereum_account.then(accounts => {
ct.methods.transfer(toaddress, web3.utils.toWei(value, "ether")).send({ 'from': ethereum.selectedAddress }).on('receipt', (receipt) => {
const result = {}
console.log(result) // I can see the result at console
return result //but I cannot get the return
})
});
} catch (error) {
console.log(error);
}
Im new for code js,
I want the function return the result , but it shows undefine!