A
A
Ankr Docs
Search…
Develop on Clover Finance
The Clover Finance chain is a powerful multi-chain tool that helps to enable a more interconnected Web 3.0 environment. They also offer a developer incentive program to encourage building on the platform.
Ankr allows users to create their own full Clover APIs with a variety of options for request call limits, archived data, and more. Ankr’s novel cluster technology allows APIs to draw from multiple nodes, offering a more reliable experience for our users.

Get started on Clover

    1.
    Login or set up an account on app.ankr.com
    2.

Network Types Available on Clover

    Mainnet

Node Modes Available on Ankr

    Full Node
Clover Cross-Chain Explorer (https://tx.clover.finance/) shows information about cross chain transactions​.

JSON-RPC Methods

Clover's approach to JSON-RPC methods is unique and not the same as the standard Ethereum JSON-RPC methods.

Example Calls

API (HTTPS) Endpoint

Go
Curl
1
package main
2
3
import (
4
"fmt"
5
"github.com/centrifuge/go-substrate-rpc-client/client"
6
"github.com/centrifuge/go-substrate-rpc-client/rpc/author"
7
"github.com/centrifuge/go-substrate-rpc-client/rpc/chain"
8
"github.com/centrifuge/go-substrate-rpc-client/rpc/state"
9
"github.com/centrifuge/go-substrate-rpc-client/rpc/system"
10
)
11
12
13
func main() {
14
const url_auth = "https://username:[email protected]/xxxxx/xxxxx/clover/full/main" // authentication
15
const url_token = "https://apis.ankr.com/xxxxx/xxxxx/clover/full/main" // token
16
17
cl,err := client.Connect("choose url_auth or url_token by your created type")
18
19
if err != nil {
20
panic(err)
21
}
22
23
newRPC, err := NewRPC(cl)
24
if err != nil {
25
panic(err)
26
}
27
28
hash, err := newRPC.Chain.GetFinalizedHead()
29
if err != nil {
30
panic(err)
31
}
32
33
fmt.Println(hash.Hex())
34
35
}
36
37
type RPC struct {
38
Author *author.Author
39
Chain *chain.Chain
40
State *state.State
41
System *system.System
42
Client *client.Client
43
}
44
45
func NewRPC(cl client.Client) (*RPC, error) {
46
st := state.NewState(cl)
47
return &RPC{
48
Author: author.NewAuthor(cl),
49
Chain: chain.NewChain(cl),
50
State: st,
51
System: system.NewSystem(cl),
52
client: cl,
53
}, nil
54
}
Copied!
1
# authentication
2
$ curl -H "Content-Type: application/json" -u "username:password" -d '{"jsonrpc":"2.0","method":"chain_getBlock","params":[],"id":1}' https://apis.ankr.com/xxxxx/xxxxx/clover/full/main
3
$ curl -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"chain_getBlock","params":[],"id":1}' https://username:[email protected]/xxxxx/xxxxx/clover/full/main
4
5
# token
6
$ curl -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"chain_getBlock","params":[],"id":1}' https://apis.ankr.com/xxxxx/xxxxx/clover/full/main
Copied!

Websocket (WSS) Endpoint

Go
Curl
1
package main
2
3
import (
4
"fmt"
5
"github.com/centrifuge/go-substrate-rpc-client/client"
6
"github.com/centrifuge/go-substrate-rpc-client/rpc/author"
7
"github.com/centrifuge/go-substrate-rpc-client/rpc/chain"
8
"github.com/centrifuge/go-substrate-rpc-client/rpc/state"
9
"github.com/centrifuge/go-substrate-rpc-client/rpc/system"
10
"time"
11
)
12
13
14
func main() {
15
const url_auth = "wss://username:[email protected]/wss/xxxxx/xxxxx/clover/full/main" // authentication
16
const url_token = "wss://apis.ankr.com/wss/xxxxx/xxxxx/clover/full/main" // token
17
18
cl,err := client.Connect("choose url_auth or url_token by your created type")
19
20
if err != nil {
21
panic(err)
22
}
23
24
newRPC, err := NewWebsocket(cl)
25
if err != nil {
26
panic(err)
27
}
28
29
sub, err := newRPC.Chain.SubscribeNewHeads()
30
if err != nil {
31
panic(err)
32
}
33
34
fmt.Println("---subscribe-----")
35
36
go func() {
37
time.Sleep(10 * time.Second)
38
fmt.Println("---unsubscribe-----")
39
sub.Unsubscribe()
40
}()
41
42
go func() {
43
for c := range sub.Chan {
44
fmt.Println(c.Number)
45
}
46
}()
47
48
<-sub.Err()
49
50
}
51
52
type Websocket struct {
53
Author *author.Author
54
Chain *chain.Chain
55
State *state.State
56
System *system.System
57
Client *client.Client
58
}
59
60
func NewWebsocket(cl client.Client) (*Websocket, error) {
61
st := state.NewState(cl)
62
return &Websocket{
63
Author: author.NewAuthor(cl),
64
Chain: chain.NewChain(cl),
65
State: st,
66
System: system.NewSystem(cl),
67
client: cl,
68
}, nil
69
}
Copied!
1
# authentication
2
$ wscat -c wss://username:[email protected]/wss/xxxxx/xxxxx/clover/full/main
3
4
# token
5
$ wscat -c wss://apis.ankr.com/wss/xxxxx/xxxxx/clover/full/main
6
7
wait connected...
8
9
# subscribe
10
> {"jsonrpc":"2.0","method":"chain_subscribeNewHeads","params":[],"id":1}
11
12
# unsubscribe
13
> {"jsonrpc":"2.0","method":"chain_unsubscribeNewHeads","params":["0xxxxxxxxxxxxxxx"],"id":1}
Copied!
Last modified 1mo ago