Hi. I want to use klaytn api service. But I never succeed. I used both python web3py and requests library. But neither of them worked. Can you help me?
My usage:
from web3 import Web3
from requests.auth import HTTPBasicAuth
klaytn = 'https://node-api.klaytnapi.com/v1/klaytn'
# The username and password are from Kayltn API service. They are accessKeyId and secretAccessKey.
web3 = Web3(Web3.HTTPProvider(klaytn, request_kwargs={
'auth': HTTPBasicAuth(username='KASKEZHJZD45D********', password='7Nuf8ixH7ywwRrz0e00tkW******')}))
print(web3.isConnected())
import requests
from requests.auth import HTTPBasicAuth
header = {'Authorization': 'Basic *********=', 'x-chain-id': '8217'}
auth = HTTPBasicAuth('KASKEZHJZD45D********', '7Nuf8ixH7ywwRrz0e00tkW******')
r = requests.get('https://node-api.klaytnapi.com/v1/klaytn', headers=header)
print(r.status_code)
Neither of them succeed. I dont’ know how to solve it.
For example. When I use bsc. I could set the rpc url to
But I don’t know how to use klaytn api service.
And another question. Is the mainnet and testnet use the same rpc url. Because it seems like this.
Thanks.