Call any RPC method
The rpc-method package allows you to make direct gRPC calls to the IoTeX blockchain. The complete gRPC API can be found in the iotex-proto GitHub repository, and all calls can be made both using the umbrella antenna.iotex object or using the rpc-method as a standalone package.

Using antenna.iotx

Javascript
Golang
1
import Antenna from "iotex-antenna";
2
3
(async () => {
4
const antenna = new Antenna("http://api.testnet.iotex.one:80");
5
6
const account = await antenna.iotx.getAccount({
7
address: "io1cl6rl2ev5dfa988qmgzg2x4hfazmp9vn2g66ng"
8
});
9
const chainMeta = await antenna.iotx.getChainMeta();
10
const actions = await antenna.iotx.getActions({
11
byIndex: { start: 1, count: 5 }
12
});
13
const blocks = await antenna.iotx.getBlockMetas({
14
byIndex: { start: 1, count: 5 }
15
});
16
})();
Copied!
1
package main
2
3
import (
4
"log"
5
6
"github.com/iotexproject/iotex-core/protogen/iotexapi"
7
8
"github.com/iotexproject/iotex-antenna-go/antenna"
9
)
10
11
func main() {
12
wallet, err := antenna.NewAntenna("api.testnet.iotex.one:80")
13
if err != nil {
14
log.Fatalf("create antenna error: %v", err)
15
}
16
17
account, err := wallet.Iotx.GetAccount(&iotexapi.GetAccountRequest{Address: "io1cl6rl2ev5dfa988qmgzg2x4hfazmp9vn2g66ng"})
18
chainMeta, err := wallet.Iotx.GetChainMeta(&iotexapi.GetChainMetaRequest{})
19
actions, err := wallet.Iotx.GetActions(&iotexapi.GetActionsRequest{
20
Lookup: &iotexapi.GetActionsRequest_ByIndex{
21
ByIndex: &iotexapi.GetActionsByIndexRequest{
22
Start: 1,
23
Count: 5,
24
},
25
},
26
})
27
blocks, err := wallet.Iotx.GetBlockMetas(&iotexapi.GetBlockMetasRequest{
28
Lookup: &iotexapi.GetBlockMetasRequest_ByIndex{
29
ByIndex: &iotexapi.GetBlockMetasByIndexRequest{
30
Start: 1,
31
Count: 5,
32
},
33
},
34
})
35
}
Copied!

Using rpc-methods a standalone package:

Javascript
Golang
1
import RpcMethod from "iotex-antenna/lib/rpc-method";
2
3
(async () => {
4
const provider = new RpcMethod("http://api.testnet.iotex.one:80");
5
6
const account = await provider.getAccount({
7
address: "io1cl6rl2ev5dfa988qmgzg2x4hfazmp9vn2g66ng"
8
});
9
const chainMeta = await provider.getChainMeta();
10
const actions = await provider.getActions({
11
byIndex: { start: 1, count: 5 }
12
});
13
const blocks = await provider.getBlockMetas({
14
byIndex: { start: 1, count: 5 }
15
});
16
})();
Copied!
1
package main
2
3
import (
4
"log"
5
6
"github.com/iotexproject/iotex-antenna-go/rpcmethod"
7
8
"github.com/iotexproject/iotex-core/protogen/iotexapi"
9
)
10
11
func main() {
12
provider, err := rpcmethod.NewRPCMethod("api.testnet.iotex.one:80")
13
if err != nil {
14
log.Fatalf("create antenna error: %v", err)
15
}
16
17
account, err := provider.GetAccount(&iotexapi.GetAccountRequest{Address: "io1cl6rl2ev5dfa988qmgzg2x4hfazmp9vn2g66ng"})
18
chainMeta, err := provider.GetChainMeta(&iotexapi.GetChainMetaRequest{})
19
actions, err := provider.GetActions(&iotexapi.GetActionsRequest{
20
Lookup: &iotexapi.GetActionsRequest_ByIndex{
21
ByIndex: &iotexapi.GetActionsByIndexRequest{
22
Start: 1,
23
Count: 5,
24
},
25
},
26
})
27
blocks, err := provider.GetBlockMetas(&iotexapi.GetBlockMetasRequest{
28
Lookup: &iotexapi.GetBlockMetasRequest_ByIndex{
29
ByIndex: &iotexapi.GetBlockMetasByIndexRequest{
30
Start: 1,
31
Count: 5,
32
},
33
},
34
})
35
}
Copied!
Last modified 6mo ago