when I try to send my transaction using infura I get this error
"The send transactions "from" field must be defined"
My problem is my web3 object. When I used Metamask and my app from a Google Chrome page I did't have problem
App.web3Provider = web3.currentProvider
web3 = new Web3(web3.currentProvider)
Now, using Truffle, I need to interact with my smart contract without metamask.
I get my web3 from infura.
App.web3Provider = new Web3.providers.HttpProvider("https://ropsten.infura.io/v3/2a8xxxxxxxxxxxxxxx")
web3 = new Web3(App.web3Provider)
(UPDATE) Iteraction with my Smart Contract
const partecipazioneContest = await $.getJSON('File.json')
App.contracts.PartecipazioneContest = TruffleContract(partecipazioneContest)
App.contracts.PartecipazioneContest.setProvider(App.web3Provider)
App.partecipazioneContest = await App.contracts.PartecipazioneContest.deployed()
Error when I make the transaction:
await App.partecipazioneContest.addUser(parameters);
I think my problem is that it does't load my account, so I create my account from my private key and i get the correct addres, but when I try to get my account with getAccount() function the accounts are empty.
await web3.eth.accounts.privateKeyToAccount('0x33434XXXXXXXXXXX13');
web3.eth.getAccounts().then(function(acc){
accounts = acc
console.log(accounts)
alert(" getAccounts " + accounts)
})
How to load my web3 returned from infura with my accounts and all the information that i need to interact with the smart contracts?
I would like to interact with my Smart contract with my wallet on Metamask passing by infura