//Sending Ethereum to an address
sendEthButton.addEventListener('click', () => {
ethereum
.request({
method: 'eth_sendTransaction',
params: [
{
from: account,
to: '0x677B38bF9FaBBc2Ef47C7030C960a0473E0979e9',
//value: value,
}
],
})
.then((txHash) => console.log(txHash))
.catch((error) => console.error);
});
Mar 21, 2021, 8:08 PM
but "value" is acting up
How can i convert this
{
"code": -32603,
"message": "value in txParams is not a string. got: (200000000000000000000)",
"data": {
"originalError": {}
}
}
{
"code": -32603,
"message": "value in txParams is not a string. got: (200000000000000000000)",
"data": {
"originalError": {}
}
}
if i cant use web3.utils anymore
can someone help me
MetaMask no longer injects web3. F
i cant use web3 anymore, so what do i use instead
Mar 21, 2021, 8:55 PM
What ?. Ofcourse you can use web3 ,
you have to use requests instead of ethereum.enable
everything else works
Mar 21, 2021, 8:57 PM
//Sending Ethereum to an address
sendEthButton.addEventListener('click', () => {
ethereum
.request({
method: 'eth_sendTransaction',
params: [
{
from: account,
to: '0x677B38bF9FaBBc2Ef47C7030C960a0473E0979e9',
value: web3.utils.toHex(value),
}
],
})
.then((txHash) => console.log(txHash))
.catch((error) => console.error);
});
sendEthButton.addEventListener('click', () => {
ethereum
.request({
method: 'eth_sendTransaction',
params: [
{
from: account,
to: '0x677B38bF9FaBBc2Ef47C7030C960a0473E0979e9',
value: web3.utils.toHex(value),
}
],
})
.then((txHash) => console.log(txHash))
.catch((error) => console.error);
});
i only use this to see if metamask is installed
if (typeof window.ethereum !== 'undefined') {
console.log('MetaMask is installed!');
}
if (typeof window.ethereum !== 'undefined') {
console.log('MetaMask is installed!');
}
Mar 21, 2021, 9:02 PM