Interacting with whitelisted smart contract

Hello team,
I have an application that interacts with a smart contract over your platform. To protect my API key, I put my contract under the whitelisted addresses. However, when I try to invoke a contract method using eth_sendRawTransaction, I get a

Rejected due to project ID settings error

error. How do I resolve this? Thank you in advance for your help!

(I believe I read somewhere that your platform does not support eth_sendRawTransaction for whitelisted contracts, but I could be wrong. In the case that it is so, is there an alternative way to interact with my whitelisted contract?)

Hi @Nicolas_Schapeler, thanks for the question and sorry you’re having this issue. To clarify, your whitelist has no errors except when you make a sendRawTransaction request?

I’m checking with the devs but using sendRawTransaction with the whitelist should be working. Can you share the code sample that you are using to make the request?

Thanks for getting back to me so fast Sean! That’s correct, when I’m doing a read-only transaction (so using call) it works, but when I try to do some operation involving writing to the blockchain I get said issue. The code below is what i use.

I’m using the web3.js framework for sending transactions and ethereumjs-tx for signing:

// Setup modules, connection and contract instance
const Web3 = require('web3');
let Tx = require('ethereumjs-tx').Transaction;
const web3 = new Web3(new Web3.providers.HttpProvider(""));
const contract = new web3.eth.Contract(contractABI, contractAddress)

// Get the nonce
web3.eth.getTransactionCount(address, function (err, nonce) {
    if (err) throw err;
    // Get the current gas price
    web3.eth.getGasPrice().then((result) => {
        // Build the transaction object
        const txObject = {
            nonce: web3.utils.toHex(nonce),
            gasLimit: web3.utils.toHex(800000),
            gasPrice: web3.utils.toHex(web3.utils.fromWei(result, 'gwei')),
            to: contractAddress,
            data: contract.methods.someContractMethod().encodeABI()

        let trx = new Tx(txObject, {'chain':'ropsten'});
        // Sign the transaction and serialize it
        let serializedTx = trx.serialize();
        // Send it off
        web3.eth.sendSignedTransaction('0x' + serializedTx.toString("hex"), function (err, txHash) {
            if(err) throw err
            else console.log("Success!")

Thank you so much again, I really appreciate it!

Any news @Sean_Infura?

Sorry for the delay @Nicolas_Schapeler , digging into this more. It might be an issue with Ropsten whitelists…

Can you message me your specific whitelist settings and project key?

Sure Sean, thanks for the effort! I tried sending you a direct message with the info, but it says I can’t send a message to you. Is there some other way I could send it to you?

Ah, can you DM me on twitter? @seanwbren

Just sent you a DM :+1:

To any future readers:
Sean and the Infura dev team were super helpful over Twitter and sorted this out for me within two days - The issue was I needed to not only add the contract I’m interacting with to the whitelist, but also the address that was sending requests to the whitelisted contract.

1 Like