tencent cloud

Feedback

Request Blockchain RPC service

Last updated: 2023-09-11 16:29:27
1. Select the Application that you want to use, and click View details.



2. Move to the bottom of the page, and configure the IP/Domain whitelist (Note: Without a whitelist, all IP addresses can use this token to call the RPC service. Adding a whitelist allows only the IP addresses in the whitelist to use this token to call the RPC service).

2.1 Add the IP/Domain whitelist: Enter the IP/Domain in the input box, and click the Add button.






2.2 Remove the IP/Domain whitelist: Click the cancel button for the corresponding IP/Domain in the whitelist.






3. Select the chain service, network, and other information you want to use, such as Mainnet in Ethereum.



4. Call the RPC service

4.1 Invoke the RPC service using command-line commands: copy the command in the example and paste it to the whitelist machine, then press Enter to execute it using curl/wscat commands.



4.2 Invoke the RPC service using code: Copy the RPC invocation address in the NETWORK ENDPOINTS and connect to it using HTTP or HTTPS.



Demo:
package test

import (
"context"
"fmt"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
"log"
"testing"
)

func Test_ws(t *testing.T) {
chainUrl := ""
client, err := ethclient.Dial(chainUrl)
if err != nil {
log.Fatal(err)
}

query := ethereum.FilterQuery{}
logs := make(chan types.Log)
sub, err := client.SubscribeFilterLogs(context.Background(), query, logs)
if err != nil {
log.Fatal(err)
}
fmt.Printf("sub: %+v\\n", sub)

for {
select {
case err := <-sub.Err():
fmt.Printf("err: %+v", err)
case vLog := <-logs:
fmt.Printf("%+v\\n", vLog.BlockNumber)
}
}
fmt.Printf("client: %+v", client)
}

func Test_http(t *testing.T) {
chainUrl := ""
client, err := ethclient.Dial(chainUrl)
if err != nil {
log.Fatal(err)
}

height, err := client.BlockNumber(context.Background())
if err != nil {
log.Fatal(err)
}
fmt.Printf("block height: %+v\\n", height)
fmt.Printf("client: %+v", client)
}

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support