Problem with using rinkeby Api

Hello guys,

Im using the infura to test my contract on rinkeby network but i got error that ‘Subscriptions are not supported with the CustomProvider’ . is the website still working or it is kind of problem in my code ?

best regards,
Ahmed

Can you provide the code where you are setting up and using the websocket connection? Can you also provide the full error response?

Hi Mike,

I created a new project here and copy the Rinkeby endpoint link to my code. Here are deploy.js package.json and the error in the order:

const HDWalletProvider = require(“truffle-hdwallet-provider”);
const Web3 = require(“web3”);
const compiledFactory = require("./build/Factory.json");

const provider = new HDWalletProvider(
"‘my mnemonic’
, ‘my url from infura’
);
const web3 = new Web3(provider);

const deploy = async () => {
const accounts = await web3.eth.getAccounts();

console.log(“Attempting to deploy from account”, accounts[0]);

const result = await new web3.eth.Contract(
JSON.parse(compiledFactory.interface)
)
.deploy({ data: “0x” + compiledFactory.bytecode })
.send({ gas: “5000000”, from: accounts[0] });

console.log(“contract deployed to”, result.options.address);
};
deploy();


{
“name”: “finalproject”,
“version”: “1.0.0”,
“description”: “”,
“main”: “index.js”,
“scripts”: {
“test”: “mocha”,
“dev”: “next dev”
},
“author”: “”,
“license”: “ISC”,
“dependencies”: {
“fs-extra”: “^7.0.1”,
“ganache-cli”: “^6.4.1”,
“mocha”: “^6.0.2”,
“next”: “^4.2.3”,
“react”: “^16.8.4”,
“react-dom”: “^16.8.4”,
“solc”: “^0.4.25”,
“truffle-hdwallet-provider”: “0.0.4”,
“web3”: “^1.0.0-beta.35”
}
}

C:\Users\User\Desktop\finalProject\ethereum>node deploy.js
Attempting to deploy from account 0x9B05cde81704dFADECdC0Ebd06779Bdf8cF76F7F
(node:15996) UnhandledPromiseRejectionWarning: Error: Subscriptions are not supported with the CustomProvider.
at CustomProvider.subscribe (C:\Users\User\Desktop\finalProject\node_modules\web3-providers\dist\web3-providers.cjs.js:1139:13)
at NewHeadsSubscription.subscribe (C:\Users\User\Desktop\finalProject\node_modules\web3-core-subscriptions\dist\web3-core-subscriptions.cjs.js:52:43)
at NewHeadsWatcher.watch (C:\Users\User\Desktop\finalProject\node_modules\web3-core-method\dist\web3-core-method.cjs.js:180:110)
at C:\Users\User\Desktop\finalProject\node_modules\web3-core-method\dist\web3-core-method.cjs.js:50:31
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:15996) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:15996) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

when i checked https://rinkeby.etherscan.io i found that it is deployed but i still get the error message, maybe it is from truffle version but Im not sure .

Looks like this may be a problem w/ web3, and may be related to this issue, https://github.com/ethereum/web3.js/issues/2405

We do not support the account APIs for security reasons we are not sure if the HDWalletProvider is in turn simulating that locally or not though, but we only support sending transactions that are signed off-node via eth_sendRawTransaction.