github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/docs/reference/gnoclient/client.md (about) 1 --- 2 id: client 3 --- 4 5 # Client 6 7 ## type [Client](<https://github.com/gnolang/gno/blob/master/gno.land/pkg/gnoclient/client.go#L8-L11>) 8 9 `Client` provides an interface for interacting with the blockchain. It is the main 10 struct of the `gnoclient` package, exposing all APIs used to communicate with a 11 Gno.land chain. 12 13 ```go 14 type Client struct { 15 Signer Signer // Signer for transaction authentication 16 RPCClient rpcclient.Client // RPC client for blockchain communication 17 } 18 ``` 19 20 ### func \(\*Client\) [AddPackage](<https://github.com/gnolang/gno/blob/master/gno.land/pkg/gnoclient/client_txs.go#L236>) 21 22 ```go 23 func (c *Client) AddPackage(cfg BaseTxCfg, msgs ...MsgAddPackage) (*ctypes.ResultBroadcastTxCommit, error) 24 ``` 25 26 `AddPackage` executes one or more [AddPackage](#type-msgaddpackage) calls on the blockchain. 27 28 ### func \(\*Client\) [Block](<https://github.com/gnolang/gno/blob/master/gno.land/pkg/gnoclient/client_queries.go#L131>) 29 30 ```go 31 func (c *Client) Block(height int64) (*ctypes.ResultBlock, error) 32 ``` 33 34 `Block` gets the latest block at height, if any. Height must be larger than 0. 35 36 ### func \(\*Client\) [BlockResult](<https://github.com/gnolang/gno/blob/master/gno.land/pkg/gnoclient/client_queries.go#L150>) 37 38 ```go 39 func (c *Client) BlockResult(height int64) (*ctypes.ResultBlockResults, error) 40 ``` 41 42 `BlockResult` gets the block results at height, if any. Height must be larger than 0. 43 44 ### func \(\*Client\) [LatestBlockHeight](<https://github.com/gnolang/gno/blob/master/gno.land/pkg/gnoclient/client_queries.go#L168>) 45 46 ```go 47 func (c *Client) LatestBlockHeight() (int64, error) 48 ``` 49 50 `LatestBlockHeight` gets the latest block height on the chain. 51 52 ### func \(\*Client\) [Call](<https://github.com/gnolang/gno/blob/master/gno.land/pkg/gnoclient/client_txs.go#L62>) 53 54 ```go 55 func (c *Client) Call(cfg BaseTxCfg, msgs ...MsgCall) (*ctypes.ResultBroadcastTxCommit, error) 56 ``` 57 58 `Call` executes a one or more [MsgCall](#type-msgcall) calls on the blockchain. 59 60 ### func \(\*Client\) [Send](<https://github.com/gnolang/gno/blob/master/gno.land/pkg/gnoclient/client_txs.go#L182>) 61 62 ```go 63 func (c *Client) Send(cfg BaseTxCfg, msgs ...MsgSend) (*ctypes.ResultBroadcastTxCommit, error) 64 ``` 65 66 `Send` executes one or more [MsgSend](#type-msgsend) calls on the blockchain. 67 68 ### func \(\*Client\) [Run](<https://github.com/gnolang/gno/blob/master/gno.land/pkg/gnoclient/client_txs.go#L118>) 69 70 ```go 71 func (c *Client) Run(cfg BaseTxCfg, msgs ...MsgRun) (*ctypes.ResultBroadcastTxCommit, error) 72 ``` 73 74 `Run` executes a one or more MsgRun calls on the blockchain. 75 76 ### func \(\*Client\) [QEval](<https://github.com/gnolang/gno/blob/master/gno.land/pkg/gnoclient/client_queries.go#L108>) 77 78 ```go 79 func (c *Client) QEval(pkgPath string, expression string) (string, *ctypes.ResultABCIQuery, error) 80 ``` 81 82 `QEval` evaluates the given expression with the realm code at `pkgPath`. 83 The `pkgPath` should include the prefix like `gno.land/`. The expression is 84 usually a function call like `Render("")`. 85 86 ### func \(*Client\) [Query](<https://github.com/gnolang/gno/blob/master/gno.land/pkg/gnoclient/client_queries.go#L22>) 87 88 ```go 89 func (c *Client) Query(cfg QueryCfg) (*ctypes.ResultABCIQuery, error) 90 ``` 91 92 `Query` performs a generic query on the blockchain. 93 94 ### func \(*Client\) [QueryAccount](<https://github.com/gnolang/gno/blob/master/gno.land/pkg/gnoclient/client_queries.go#L39>) 95 96 ```go 97 func (c *Client) QueryAccount(addr crypto.Address) (*std.BaseAccount, *ctypes.ResultABCIQuery, error) 98 ``` 99 100 `QueryAccount` retrieves account information for a given address. 101 102 ### func \(*Client\) [QueryAppVersion](<https://github.com/gnolang/gno/blob/master/gno.land/pkg/gnoclient/client_queries.go#L65>) 103 104 ```go 105 func (c *Client) QueryAppVersion() (string, *ctypes.ResultABCIQuery, error) 106 ``` 107 108 `QueryAppVersion` retrieves information about the Gno.land app version. 109 110 ### func \(*Client\) [Render](<https://github.com/gnolang/gno/blob/master/gno.land/pkg/gnoclient/client_queries.go#L85>) 111 112 ```go 113 func (c *Client) Render(pkgPath string, args string) (string, *ctypes.ResultABCIQuery, error) 114 ``` 115 116 `Render` calls the Render function for pkgPath with optional args. The `pkgPath` 117 should include the prefix like `gno.land/`. This is similar to using a browser 118 URL `<testnet>/<pkgPath>:<args>` where `<pkgPath>` doesn't have the prefix like 119 `gno.land/`. 120 121 ## type [BaseTxCfg](<https://github.com/gnolang/gno/blob/master/gno.land/pkg/gnoclient/client_txs.go#L27-L33>) 122 123 `BaseTxCfg` defines the base transaction configuration, shared by all message 124 types. 125 126 ```go 127 type BaseTxCfg struct { 128 GasFee string // Gas fee 129 GasWanted int64 // Gas wanted 130 AccountNumber uint64 // Account number 131 SequenceNumber uint64 // Sequence number 132 Memo string // Memo 133 } 134 ``` 135 136 ## type [MsgAddPackage](<https://github.com/gnolang/gno/blob/master/gno.land/pkg/gnoclient/client_txs.go#L59-L59>) 137 138 `MsgAddPackage` \- syntax sugar for `vm.MsgAddPackage`. 139 140 ```go 141 type MsgAddPackage struct { 142 Package *std.MemPackage // Package to add 143 Deposit string // Coin deposit 144 } 145 ``` 146 147 ## type [MsgCall](<https://github.com/gnolang/gno/blob/master/gno.land/pkg/gnoclient/client_txs.go#L36-L41>) 148 149 `MsgCall` \- syntax sugar for `vm.MsgCall`. 150 151 ```go 152 type MsgCall struct { 153 PkgPath string // Package path 154 FuncName string // Function name 155 Args []string // Function arguments 156 Send string // Send amount 157 } 158 ``` 159 160 ## type [MsgRun](<https://github.com/gnolang/gno/blob/master/gno.land/pkg/gnoclient/client_txs.go#L50-L53>) 161 162 `MsgRun` \- syntax sugar for `vm.MsgRun`. 163 164 ```go 165 type MsgRun struct { 166 Package *std.MemPackage // Package to run 167 Send string // Send amount 168 } 169 ``` 170 171 ## type [MsgSend](<https://github.com/gnolang/gno/blob/master/gno.land/pkg/gnoclient/client_txs.go#L44-L47>) 172 173 `MsgSend` \- syntax sugar for `bank.MsgSend`. 174 175 ```go 176 type MsgSend struct { 177 ToAddress crypto.Address // Send to address 178 Send string // Send amount 179 } 180 ``` 181 182 ## type [QueryCfg](<https://github.com/gnolang/gno/blob/master/gno.land/pkg/gnoclient/client_queries.go#L15-L19>) 183 184 `QueryCfg` contains configuration options for performing ABCI queries. 185 186 ```go 187 type QueryCfg struct { 188 Path string // Query path 189 Data []byte // Query data 190 rpcclient.ABCIQueryOptions // ABCI query options 191 } 192 ```