Open m-bo-one opened 2 years ago
I have tried to reproduce the issue and I can't connect to WebSocket provider as well:
Full code:
const Web3 = require('web3');
/**
* BEFORE USING THIS SCRIPT MAKE SURE TO REPLACE:
* - <YOUR_CONTRACT_ABI>
* - <YOUR_CONTRACT_ADDRESS>
* - CONTRACT_ADDRESS variable value
* - YOUR_READ_FUNCTION_NAME method name
* - YOUR_WRITE_FUNCTION_NAME method name
*/
const ACCOUNT_PRIVATE_KEY = '0xd9066ff9f753a1898709b568119055660a77d9aae4d7a4ad677b8fb3d2a571e5'; // Replace this with your Ethereum private key with funds on Layer 2.
const CONTRACT_ABI = [
{
"inputs": [],
"stateMutability": "payable",
"type": "constructor"
},
{
"inputs": [],
"name": "get",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "x",
"type": "uint256"
}
],
"name": "set",
"outputs": [],
"stateMutability": "payable",
"type": "function"
}
]; // this should be an Array []
const CONTRACT_ADDRESS = '0xd4A8b3018f0c79f6BD3375C89a5Db47ca11A1C35';
const web3 = new Web3('wss://godwoken-testnet-v1.ckbapp.dev/ws');
const account = web3.eth.accounts.wallet.add(ACCOUNT_PRIVATE_KEY);
async function readCall() {
const contract = new web3.eth.Contract(CONTRACT_ABI, CONTRACT_ADDRESS);
const callResult = await contract.methods.get().call({
from: account.address
});
console.log(`Read call result: ${callResult}`);
}
async function writeCall() {
const contract = new web3.eth.Contract(CONTRACT_ABI, CONTRACT_ADDRESS);
const tx = contract.methods.set(333).send(
{
from: account.address,
gas: 6000000
}
);
tx.on('transactionHash', hash => console.log(`Write call transaction hash: ${hash}`));
const receipt = await tx;
console.log('Write call transaction receipt: ', receipt);
}
(async () => {
const balance = BigInt(await web3.eth.getBalance(account.address));
if (balance === 0n) {
console.log(`Insufficient balance. Can't issue a smart contract call. Please deposit funds to your Ethereum address: ${account.address}`);
return;
}
console.log('Calling contract...');
// Check smart contract state before state change.
await readCall();
// Change smart contract state.
await writeCall();
// Check smart contract state after state change.
await readCall();
})();
@jiangxianliang007 seems the testnet TLS is broken? I check web3 websocket works on local development.
we have updated the testnet ws configuration, can you check if it works now? @Kuzirashi @m-bo-one
we have updated the testnet ws configuration, can you check if it works now? @Kuzirashi @m-bo-one
Works for me now
websockat works, however blockscout has the same issue:
2022-06-06T12:48:57.898 [notice] TLS :client: In state :wait_cert_cr at ssl_handshake.erl:2017 generated CLIENT ALERT: Fatal - Handshake Failure
- {:bad_cert, :hostname_check_failed}
websockat works, however blockscout has the same issue:
2022-06-06T12:48:57.898 [notice] TLS :client: In state :wait_cert_cr at ssl_handshake.erl:2017 generated CLIENT ALERT: Fatal - Handshake Failure - {:bad_cert, :hostname_check_failed}
Could be caused by this OTP problem described here:
By default OTP does not permit wildcards in SAN extensions, unless you opt-in using {customize_hostname_check, [{match_fun, public_key:pkix_verify_hostname_match_fun(https)}]}
(or, to be precise, by default it recognises wildcards only in Subject CN, and only when no SAN extension is present)
From: https://github.com/benoitc/hackney/issues/624#issuecomment-631340823
when I am trying to connect blockscout exporer with
wss://godwoken-testnet-v1.ckbapp.dev/ws
url (https://github.com/nervosnetwork/godwoken-info/tree/main/testnet_v1_1#godwoken-web3-rpc), explorer, I am gettingIf I remove wss, just ws without tls, blockscout just hang. I also verified, that through websocat I am getting an error