Hello, im trying to send a transaction to a smart contract on the ropsten network.
const amount = "0.0004";
const amountToSend = web3.utils.toWei(amount, "ether"); // Convert to wei value
web3.eth.sendTransaction({
from: '0xB1a314e66784a7baB3dD1247D5499936e3D74558',
to: tkn.options.address,
value: amountToSend
}).then( function(tx) { ;
console.log("Transaction: ", tx);
});
i have the function on the contract -
contract MokkaToken is ERC20,
Ownable {
mapping(address => uint256) balances;
address public admin;
uint256 token_totalSupply = 1000000;
address public _tokenAddress;
string public iden;
constructor()public ERC20("MokkaToken", "MKT") {
admin = owner();
transferOwnership(admin);
_mint(admin, token_totalSupply * 10 ** uint256(18));
}
function sendAssets() public payable {
iden = "sendAssets got called";
transfer(msg.sender,msg.value);
}
receive() external payable {
iden = "fallback function got called";
}
and i'm getting the error -
UnhandledPromiseRejectionWarning: Error: Returned error: The method eth_sendTransaction does not exist/is not available
Did i do something wrong? or there is a problem with sending transaction with web3.js and infura?
May 18, 2021, 2:23 PM