[英]How to connect to a protected infura project with web3?
I'm using web3 in node js to create new Web3.providers.HttpProvider with a infura project, wich is configure with "Require project secret for all requests"我在节点 js 中使用 web3 来创建新的 Web3.providers.HttpProvider 与 infura 项目,其中配置为“要求所有请求的项目机密”
In infura:在英法拉:
https://infura.io/docs/gettingStarted/authentication https://infura.io/docs/gettingStarted/authentication
explains calling by curl is:解释调用 curl 是:
curl --user :YOUR-PROJECT-SECRET \\ https://.infura.io/v3/YOUR-PROJECT-ID curl --user :YOUR-PROJECT-SECRET \\ https://.infura.io/v3/YOUR-PROJECT-ID
I've used:我用过:
const client = new Web3(new Web3.providers.HttpProvider('https://YOUR-PROJECT-SECRET@<network>.infura.io/v3/YOUR-PROJECT-ID');
And it doesn't work.它不起作用。
How can I add the --user tag and its value into new Web3.providers.HttpProvider, please?请问如何将 --user 标签及其值添加到新的 Web3.providers.HttpProvider 中?
Thanks in advance!提前致谢!
I'm awsering my question:我正在回答我的问题:
I solved it adding ":" before YOUR-PROJECT-SECRET, like this:我解决了在你的项目秘密之前添加“:”的问题,就像这样:
const client = new Web3(new Web3.providers.HttpProvider('https://:YOUR-PROJECT-SECRET@<network>.infura.io/v3/YOUR-PROJECT-ID');
It's working now!它现在工作了!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.