github.com/0chain/gosdk@v1.17.11/zcnbridge/README.MD (about) 1 <!-- Code generated by gomarkdoc. DO NOT EDIT --> 2 3 # zcnbridge 4 5 ```go 6 import "github.com/0chain/gosdk/zcnbridge" 7 ``` 8 9 ## Index 10 11 - [Constants](<#constants>) 12 - [Variables](<#variables>) 13 - [func AccountExists\(homedir, address string\) bool](<#AccountExists>) 14 - [func ConfirmEthereumTransaction\(hash string, times int, duration time.Duration\) \(int, error\)](<#ConfirmEthereumTransaction>) 15 - [func ConvertIntToHex\(value int64\) string](<#ConvertIntToHex>) 16 - [func CreateKeyStorage\(homedir, password string\) error](<#CreateKeyStorage>) 17 - [func DeleteAccount\(homedir, address string\) bool](<#DeleteAccount>) 18 - [func EncodePackInt64\(key string, param int64\) common.Hash](<#EncodePackInt64>) 19 - [func GetAuthorizer\(id string, cb zcncore.GetInfoCallback\) \(err error\)](<#GetAuthorizer>) 20 - [func GetAuthorizers\(active bool, cb zcncore.GetInfoCallback\) \(err error\)](<#GetAuthorizers>) 21 - [func GetGlobalConfig\(cb zcncore.GetInfoCallback\) \(err error\)](<#GetGlobalConfig>) 22 - [func GetTransactionStatus\(hash string\) \(int, error\)](<#GetTransactionStatus>) 23 - [func ImportAccount\(homedir, mnemonic, password string, accountAddrIndex ...AccountAddressIndex\) \(string, error\)](<#ImportAccount>) 24 - [func ListStorageAccounts\(homedir string\) \[\]common.Address](<#ListStorageAccounts>) 25 - [type AccountAddressIndex](<#AccountAddressIndex>) 26 - [type AlchemyGasEstimationRequest](<#AlchemyGasEstimationRequest>) 27 - [type AuthorizerNode](<#AuthorizerNode>) 28 - [type AuthorizerNodesResponse](<#AuthorizerNodesResponse>) 29 - [type AuthorizerResponse](<#AuthorizerResponse>) 30 - [type BancorTokenDetails](<#BancorTokenDetails>) 31 - [type BridgeClient](<#BridgeClient>) 32 - [func NewBridgeClient\(bridgeAddress, tokenAddress, authorizersAddress, uniswapAddress, ethereumAddress, ethereumNodeURL, password string, gasLimit uint64, consensusThreshold float64, ethereumClient EthereumClient, transactionProvider transaction.TransactionProvider, keyStore KeyStore\) \*BridgeClient](<#NewBridgeClient>) 33 - [func SetupBridgeClientSDK\(cfg \*BridgeSDKConfig\) \*BridgeClient](<#SetupBridgeClientSDK>) 34 - [func \(b \*BridgeClient\) AddEthereumAuthorizer\(ctx context.Context, address common.Address\) \(\*types.Transaction, error\)](<#BridgeClient.AddEthereumAuthorizer>) 35 - [func \(b \*BridgeClient\) AddEthereumAuthorizers\(configDir string\)](<#BridgeClient.AddEthereumAuthorizers>) 36 - [func \(b \*BridgeClient\) ApproveUSDCSwap\(ctx context.Context, source uint64\) \(\*types.Transaction, error\)](<#BridgeClient.ApproveUSDCSwap>) 37 - [func \(b \*BridgeClient\) BurnWZCN\(ctx context.Context, amountTokens uint64\) \(\*types.Transaction, error\)](<#BridgeClient.BurnWZCN>) 38 - [func \(b \*BridgeClient\) BurnZCN\(ctx context.Context, amount, txnfee uint64\) \(transaction.Transaction, error\)](<#BridgeClient.BurnZCN>) 39 - [func \(b \*BridgeClient\) CreateSignedTransactionFromKeyStore\(client EthereumClient, gasLimitUnits uint64\) \*bind.TransactOpts](<#BridgeClient.CreateSignedTransactionFromKeyStore>) 40 - [func \(b \*BridgeClient\) EstimateBurnWZCNGasAmount\(ctx context.Context, from, to, amountTokens string\) \(float64, error\)](<#BridgeClient.EstimateBurnWZCNGasAmount>) 41 - [func \(b \*BridgeClient\) EstimateGasPrice\(ctx context.Context\) \(float64, error\)](<#BridgeClient.EstimateGasPrice>) 42 - [func \(b \*BridgeClient\) EstimateMintWZCNGasAmount\(ctx context.Context, from, to, zcnTransactionRaw, amountToken string, nonceRaw int64, signaturesRaw \[\]\[\]byte\) \(float64, error\)](<#BridgeClient.EstimateMintWZCNGasAmount>) 43 - [func \(b \*BridgeClient\) GetETHSwapAmount\(ctx context.Context, source uint64\) \(\*big.Int, error\)](<#BridgeClient.GetETHSwapAmount>) 44 - [func \(b \*BridgeClient\) GetTokenBalance\(\) \(\*big.Int, error\)](<#BridgeClient.GetTokenBalance>) 45 - [func \(b \*BridgeClient\) GetUserNonceMinted\(ctx context.Context, rawEthereumAddress string\) \(\*big.Int, error\)](<#BridgeClient.GetUserNonceMinted>) 46 - [func \(b \*BridgeClient\) IncreaseBurnerAllowance\(ctx context.Context, allowanceAmount uint64\) \(\*types.Transaction, error\)](<#BridgeClient.IncreaseBurnerAllowance>) 47 - [func \(b \*BridgeClient\) MintWZCN\(ctx context.Context, payload \*ethereum.MintPayload\) \(\*types.Transaction, error\)](<#BridgeClient.MintWZCN>) 48 - [func \(b \*BridgeClient\) MintZCN\(ctx context.Context, payload \*zcnsc.MintPayload\) \(string, error\)](<#BridgeClient.MintZCN>) 49 - [func \(b \*BridgeClient\) NFTConfigGetAddress\(ctx context.Context, key string\) \(string, string, error\)](<#BridgeClient.NFTConfigGetAddress>) 50 - [func \(b \*BridgeClient\) NFTConfigGetUint256\(ctx context.Context, key string, keyParam ...int64\) \(string, int64, error\)](<#BridgeClient.NFTConfigGetUint256>) 51 - [func \(b \*BridgeClient\) NFTConfigSetAddress\(ctx context.Context, key, address string\) \(\*types.Transaction, error\)](<#BridgeClient.NFTConfigSetAddress>) 52 - [func \(b \*BridgeClient\) NFTConfigSetUint256\(ctx context.Context, key string, value int64\) \(\*types.Transaction, error\)](<#BridgeClient.NFTConfigSetUint256>) 53 - [func \(b \*BridgeClient\) NFTConfigSetUint256Raw\(ctx context.Context, key common.Hash, value int64\) \(\*types.Transaction, error\)](<#BridgeClient.NFTConfigSetUint256Raw>) 54 - [func \(b \*BridgeClient\) QueryEthereumBurnEvents\(startNonce string\) \(\[\]\*ethereum.BurnEvent, error\)](<#BridgeClient.QueryEthereumBurnEvents>) 55 - [func \(b \*BridgeClient\) QueryEthereumMintPayload\(zchainBurnHash string\) \(\*ethereum.MintPayload, error\)](<#BridgeClient.QueryEthereumMintPayload>) 56 - [func \(b \*BridgeClient\) QueryZChainMintPayload\(ethBurnHash string\) \(\*zcnsc.MintPayload, error\)](<#BridgeClient.QueryZChainMintPayload>) 57 - [func \(b \*BridgeClient\) RemoveEthereumAuthorizer\(ctx context.Context, address common.Address\) \(\*types.Transaction, error\)](<#BridgeClient.RemoveEthereumAuthorizer>) 58 - [func \(b \*BridgeClient\) ResetUserNonceMinted\(ctx context.Context\) \(\*types.Transaction, error\)](<#BridgeClient.ResetUserNonceMinted>) 59 - [func \(b \*BridgeClient\) SignWithEthereumChain\(message string\) \(\[\]byte, error\)](<#BridgeClient.SignWithEthereumChain>) 60 - [func \(b \*BridgeClient\) SwapETH\(ctx context.Context, source uint64, target uint64\) \(\*types.Transaction, error\)](<#BridgeClient.SwapETH>) 61 - [func \(b \*BridgeClient\) SwapUSDC\(ctx context.Context, source uint64, target uint64\) \(\*types.Transaction, error\)](<#BridgeClient.SwapUSDC>) 62 - [func \(b \*BridgeClient\) VerifyZCNTransaction\(ctx context.Context, hash string\) \(transaction.Transaction, error\)](<#BridgeClient.VerifyZCNTransaction>) 63 - [type BridgeSDKConfig](<#BridgeSDKConfig>) 64 - [type DetailedAccount](<#DetailedAccount>) 65 - [type EthereumBurnEvents](<#EthereumBurnEvents>) 66 - [func \(r \*EthereumBurnEvents\) Data\(\) interface\{\}](<#EthereumBurnEvents.Data>) 67 - [func \(r \*EthereumBurnEvents\) Error\(\) error](<#EthereumBurnEvents.Error>) 68 - [func \(r \*EthereumBurnEvents\) GetAuthorizerID\(\) string](<#EthereumBurnEvents.GetAuthorizerID>) 69 - [func \(r \*EthereumBurnEvents\) SetAuthorizerID\(id string\)](<#EthereumBurnEvents.SetAuthorizerID>) 70 - [type EthereumClient](<#EthereumClient>) 71 - [type GasEstimationRequest](<#GasEstimationRequest>) 72 - [type GasPriceEstimationResult](<#GasPriceEstimationResult>) 73 - [type JobError](<#JobError>) 74 - [func \(e \*JobError\) MarshalJSON\(\) \(\[\]byte, error\)](<#JobError.MarshalJSON>) 75 - [func \(e \*JobError\) UnmarshalJSON\(buf \[\]byte\) error](<#JobError.UnmarshalJSON>) 76 - [type JobResult](<#JobResult>) 77 - [type JobStatus](<#JobStatus>) 78 - [type KeyStore](<#KeyStore>) 79 - [func NewKeyStore\(path string\) KeyStore](<#NewKeyStore>) 80 - [type ProofEthereumBurn](<#ProofEthereumBurn>) 81 - [type ProofZCNBurn](<#ProofZCNBurn>) 82 - [func \(r \*ProofZCNBurn\) Data\(\) interface\{\}](<#ProofZCNBurn.Data>) 83 - [func \(r \*ProofZCNBurn\) Error\(\) error](<#ProofZCNBurn.Error>) 84 - [func \(r \*ProofZCNBurn\) GetAuthorizerID\(\) string](<#ProofZCNBurn.GetAuthorizerID>) 85 - [func \(r \*ProofZCNBurn\) SetAuthorizerID\(id string\)](<#ProofZCNBurn.SetAuthorizerID>) 86 - [type WZCNBurnEvent](<#WZCNBurnEvent>) 87 - [func \(r \*WZCNBurnEvent\) Data\(\) interface\{\}](<#WZCNBurnEvent.Data>) 88 - [func \(r \*WZCNBurnEvent\) Error\(\) error](<#WZCNBurnEvent.Error>) 89 - [func \(r \*WZCNBurnEvent\) GetAuthorizerID\(\) string](<#WZCNBurnEvent.GetAuthorizerID>) 90 - [func \(r \*WZCNBurnEvent\) SetAuthorizerID\(id string\)](<#WZCNBurnEvent.SetAuthorizerID>) 91 92 93 ## Constants 94 95 <a name="TenderlyProvider"></a> 96 97 ```go 98 const ( 99 TenderlyProvider = iota 100 AlchemyProvider 101 UnknownProvider 102 ) 103 ``` 104 105 <a name="UniswapRouterAddress"></a> 106 107 ```go 108 const ( 109 UniswapRouterAddress = "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D" 110 UsdcTokenAddress = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" 111 WethTokenAddress = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" 112 ) 113 ``` 114 115 <a name="EthereumWalletStorageDir"></a> 116 117 ```go 118 const ( 119 EthereumWalletStorageDir = "wallets" 120 ) 121 ``` 122 123 ## Variables 124 125 <a name="DefaultClientIDEncoder"></a> 126 127 ```go 128 var ( 129 DefaultClientIDEncoder = func(id string) []byte { 130 result, err := hex.DecodeString(id) 131 if err != nil { 132 Logger.Fatal(err) 133 } 134 return result 135 } 136 ) 137 ``` 138 139 <a name="Logger"></a> 140 141 ```go 142 var Logger logger.Logger 143 ``` 144 145 <a name="AccountExists"></a> 146 ## func [AccountExists](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/keystore.go#L92>) 147 148 ```go 149 func AccountExists(homedir, address string) bool 150 ``` 151 152 AccountExists checks if account exists 153 154 <a name="ConfirmEthereumTransaction"></a> 155 ## func [ConfirmEthereumTransaction](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge_helper.go#L54>) 156 157 ```go 158 func ConfirmEthereumTransaction(hash string, times int, duration time.Duration) (int, error) 159 ``` 160 161 162 163 <a name="ConvertIntToHex"></a> 164 ## func [ConvertIntToHex](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge_helper.go#L99>) 165 166 ```go 167 func ConvertIntToHex(value int64) string 168 ``` 169 170 ConvertIntToHex converts given int value to hex string. 171 172 <a name="CreateKeyStorage"></a> 173 ## func [CreateKeyStorage](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/keystore.go#L116>) 174 175 ```go 176 func CreateKeyStorage(homedir, password string) error 177 ``` 178 179 CreateKeyStorage create, restore or unlock key storage 180 181 <a name="DeleteAccount"></a> 182 ## func [DeleteAccount](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/keystore.go#L73>) 183 184 ```go 185 func DeleteAccount(homedir, address string) bool 186 ``` 187 188 DeleteAccount deletes account from wallet 189 190 <a name="EncodePackInt64"></a> 191 ## func [EncodePackInt64](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge.go#L236>) 192 193 ```go 194 func EncodePackInt64(key string, param int64) common.Hash 195 ``` 196 197 EncodePackInt do abi.encodedPack\(string, int\), it is used for setting plan id for royalty 198 199 <a name="GetAuthorizer"></a> 200 ## func [GetAuthorizer](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/rest.go#L75>) 201 202 ```go 203 func GetAuthorizer(id string, cb zcncore.GetInfoCallback) (err error) 204 ``` 205 206 GetAuthorizer returned authorizer by ID 207 208 <a name="GetAuthorizers"></a> 209 ## func [GetAuthorizers](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/rest.go#L94>) 210 211 ```go 212 func GetAuthorizers(active bool, cb zcncore.GetInfoCallback) (err error) 213 ``` 214 215 GetAuthorizers Returns all or only active authorizers 216 217 <a name="GetGlobalConfig"></a> 218 ## func [GetGlobalConfig](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/rest.go#L104>) 219 220 ```go 221 func GetGlobalConfig(cb zcncore.GetInfoCallback) (err error) 222 ``` 223 224 GetGlobalConfig Returns global config 225 226 <a name="GetTransactionStatus"></a> 227 ## func [GetTransactionStatus](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge_helper.go#L45>) 228 229 ```go 230 func GetTransactionStatus(hash string) (int, error) 231 ``` 232 233 234 235 <a name="ImportAccount"></a> 236 ## func [ImportAccount](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/keystore.go#L135>) 237 238 ```go 239 func ImportAccount(homedir, mnemonic, password string, accountAddrIndex ...AccountAddressIndex) (string, error) 240 ``` 241 242 ImportAccount imports account using mnemonic 243 244 <a name="ListStorageAccounts"></a> 245 ## func [ListStorageAccounts](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/keystore.go#L62>) 246 247 ```go 248 func ListStorageAccounts(homedir string) []common.Address 249 ``` 250 251 ListStorageAccounts List available accounts 252 253 <a name="AccountAddressIndex"></a> 254 ## type [AccountAddressIndex](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/keystore.go#L128-L132>) 255 256 257 258 ```go 259 type AccountAddressIndex struct { 260 AccountIndex int 261 AddressIndex int 262 Bip32 bool 263 } 264 ``` 265 266 <a name="AlchemyGasEstimationRequest"></a> 267 ## type [AlchemyGasEstimationRequest](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge_helper.go#L14-L19>) 268 269 AlchemyGasEstimationRequest describes request used for Alchemy enhanced JSON\-RPC API. 270 271 ```go 272 type AlchemyGasEstimationRequest struct { 273 From string `json:"from"` 274 To string `json:"to"` 275 Value string `json:"value"` 276 Data string `json:"data"` 277 } 278 ``` 279 280 <a name="AuthorizerNode"></a> 281 ## type [AuthorizerNode](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/rest.go#L41-L44>) 282 283 284 285 ```go 286 type AuthorizerNode struct { 287 ID string `json:"id"` 288 URL string `json:"url"` 289 } 290 ``` 291 292 <a name="AuthorizerNodesResponse"></a> 293 ## type [AuthorizerNodesResponse](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/rest.go#L37-L39>) 294 295 296 297 ```go 298 type AuthorizerNodesResponse struct { 299 Nodes []*AuthorizerNode `json:"nodes"` 300 } 301 ``` 302 303 <a name="AuthorizerResponse"></a> 304 ## type [AuthorizerResponse](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/rest.go#L15-L35>) 305 306 307 308 ```go 309 type AuthorizerResponse struct { 310 AuthorizerID string `json:"id"` 311 URL string `json:"url"` 312 313 // Configuration 314 Fee common.Balance `json:"fee"` 315 316 // Geolocation 317 Latitude float64 `json:"latitude"` 318 Longitude float64 `json:"longitude"` 319 320 // Stats 321 LastHealthCheck int64 `json:"last_health_check"` 322 323 // stake_pool_settings 324 DelegateWallet string `json:"delegate_wallet"` 325 MinStake common.Balance `json:"min_stake"` 326 MaxStake common.Balance `json:"max_stake"` 327 NumDelegates int `json:"num_delegates"` 328 ServiceCharge float64 `json:"service_charge"` 329 } 330 ``` 331 332 <a name="BancorTokenDetails"></a> 333 ## type [BancorTokenDetails](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge_helper.go#L34-L43>) 334 335 BancorTokenDetails describes Bancor ZCN zcntoken pool details 336 337 ```go 338 type BancorTokenDetails struct { 339 Data struct { 340 Rate struct { 341 ETH string `json:"eth"` 342 BNT string `json:"bnt"` 343 USDC string `json:"usd"` 344 EURC string `json:"eur"` 345 } 346 } `json:"data"` 347 } 348 ``` 349 350 <a name="BridgeClient"></a> 351 ## type [BridgeClient](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/config.go#L49-L67>) 352 353 354 355 ```go 356 type BridgeClient struct { 357 BridgeAddress, 358 TokenAddress, 359 AuthorizersAddress, 360 UniswapAddress, 361 NFTConfigAddress, 362 EthereumAddress, 363 EthereumNodeURL, 364 Password string 365 366 BancorAPIURL string 367 368 ConsensusThreshold float64 369 GasLimit uint64 370 // contains filtered or unexported fields 371 } 372 ``` 373 374 <a name="NewBridgeClient"></a> 375 ### func [NewBridgeClient](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/config.go#L70-L82>) 376 377 ```go 378 func NewBridgeClient(bridgeAddress, tokenAddress, authorizersAddress, uniswapAddress, ethereumAddress, ethereumNodeURL, password string, gasLimit uint64, consensusThreshold float64, ethereumClient EthereumClient, transactionProvider transaction.TransactionProvider, keyStore KeyStore) *BridgeClient 379 ``` 380 381 NewBridgeClient creates BridgeClient with the given parameters. 382 383 <a name="SetupBridgeClientSDK"></a> 384 ### func [SetupBridgeClientSDK](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/config.go#L123>) 385 386 ```go 387 func SetupBridgeClientSDK(cfg *BridgeSDKConfig) *BridgeClient 388 ``` 389 390 SetupBridgeClientSDK initializes new bridge client. Meant to be used from standalone application with 0chain SDK initialized. 391 392 <a name="BridgeClient.AddEthereumAuthorizer"></a> 393 ### func \(\*BridgeClient\) [AddEthereumAuthorizer](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge.go#L118>) 394 395 ```go 396 func (b *BridgeClient) AddEthereumAuthorizer(ctx context.Context, address common.Address) (*types.Transaction, error) 397 ``` 398 399 AddEthereumAuthorizer Adds authorizer to Ethereum bridge. Only contract deployer can call this method 400 401 <a name="BridgeClient.AddEthereumAuthorizers"></a> 402 ### func \(\*BridgeClient\) [AddEthereumAuthorizers](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge.go#L149>) 403 404 ```go 405 func (b *BridgeClient) AddEthereumAuthorizers(configDir string) 406 ``` 407 408 409 410 <a name="BridgeClient.ApproveUSDCSwap"></a> 411 ### func \(\*BridgeClient\) [ApproveUSDCSwap](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge.go#L668>) 412 413 ```go 414 func (b *BridgeClient) ApproveUSDCSwap(ctx context.Context, source uint64) (*types.Transaction, error) 415 ``` 416 417 ApproveUSDCSwap provides opportunity to approve swap operation for ERC20 tokens 418 419 <a name="BridgeClient.BurnWZCN"></a> 420 ### func \(\*BridgeClient\) [BurnWZCN](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge.go#L551>) 421 422 ```go 423 func (b *BridgeClient) BurnWZCN(ctx context.Context, amountTokens uint64) (*types.Transaction, error) 424 ``` 425 426 BurnWZCN Burns WZCN tokens on behalf of the 0ZCN client amountTokens \- ZCN tokens clientID \- 0ZCN client ERC20 signature: "burn\(uint256,bytes\)" 427 428 <a name="BridgeClient.BurnZCN"></a> 429 ### func \(\*BridgeClient\) [BurnZCN](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge.go#L621>) 430 431 ```go 432 func (b *BridgeClient) BurnZCN(ctx context.Context, amount, txnfee uint64) (transaction.Transaction, error) 433 ``` 434 435 BurnZCN burns ZCN tokens before conversion from ZCN to WZCN as a first step 436 437 <a name="BridgeClient.CreateSignedTransactionFromKeyStore"></a> 438 ### func \(\*BridgeClient\) [CreateSignedTransactionFromKeyStore](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge.go#L70>) 439 440 ```go 441 func (b *BridgeClient) CreateSignedTransactionFromKeyStore(client EthereumClient, gasLimitUnits uint64) *bind.TransactOpts 442 ``` 443 444 445 446 <a name="BridgeClient.EstimateBurnWZCNGasAmount"></a> 447 ### func \(\*BridgeClient\) [EstimateBurnWZCNGasAmount](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge.go#L1013>) 448 449 ```go 450 func (b *BridgeClient) EstimateBurnWZCNGasAmount(ctx context.Context, from, to, amountTokens string) (float64, error) 451 ``` 452 453 EstimateBurnWZCNGasAmount performs gas amount estimation for the given wzcn burn transaction. 454 455 <a name="BridgeClient.EstimateGasPrice"></a> 456 ### func \(\*BridgeClient\) [EstimateGasPrice](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge.go#L1111>) 457 458 ```go 459 func (b *BridgeClient) EstimateGasPrice(ctx context.Context) (float64, error) 460 ``` 461 462 EstimateGasPrice performs gas estimation for the given transaction. 463 464 <a name="BridgeClient.EstimateMintWZCNGasAmount"></a> 465 ### func \(\*BridgeClient\) [EstimateMintWZCNGasAmount](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge.go#L1043-L1044>) 466 467 ```go 468 func (b *BridgeClient) EstimateMintWZCNGasAmount(ctx context.Context, from, to, zcnTransactionRaw, amountToken string, nonceRaw int64, signaturesRaw [][]byte) (float64, error) 469 ``` 470 471 EstimateMintWZCNGasAmount performs gas amount estimation for the given wzcn mint transaction. 472 473 <a name="BridgeClient.GetETHSwapAmount"></a> 474 ### func \(\*BridgeClient\) [GetETHSwapAmount](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge.go#L701>) 475 476 ```go 477 func (b *BridgeClient) GetETHSwapAmount(ctx context.Context, source uint64) (*big.Int, error) 478 ``` 479 480 GetETHSwapAmount retrieves ETH swap amount from the given source. 481 482 <a name="BridgeClient.GetTokenBalance"></a> 483 ### func \(\*BridgeClient\) [GetTokenBalance](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge.go#L393>) 484 485 ```go 486 func (b *BridgeClient) GetTokenBalance() (*big.Int, error) 487 ``` 488 489 GetTokenBalance returns balance of the current client for the zcntoken address 490 491 <a name="BridgeClient.GetUserNonceMinted"></a> 492 ### func \(\*BridgeClient\) [GetUserNonceMinted](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge.go#L444>) 493 494 ```go 495 func (b *BridgeClient) GetUserNonceMinted(ctx context.Context, rawEthereumAddress string) (*big.Int, error) 496 ``` 497 498 GetUserNonceMinted Returns nonce for a specified Ethereum address 499 500 <a name="BridgeClient.IncreaseBurnerAllowance"></a> 501 ### func \(\*BridgeClient\) [IncreaseBurnerAllowance](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge.go#L344>) 502 503 ```go 504 func (b *BridgeClient) IncreaseBurnerAllowance(ctx context.Context, allowanceAmount uint64) (*types.Transaction, error) 505 ``` 506 507 IncreaseBurnerAllowance Increases allowance for bridge contract address to transfer ERC\-20 tokens on behalf of the zcntoken owner to the Burn TokenPool During the burn the script transfers amount from zcntoken owner to the bridge burn zcntoken pool Example: owner wants to burn some amount. The contract will transfer some amount from owner address to the pool. So the owner must call IncreaseAllowance of the WZCN zcntoken with 2 parameters: spender address which is the bridge contract and amount to be burned \(transferred\) Token signature: "increaseApproval\(address,uint256\)" 508 509 <a name="BridgeClient.MintWZCN"></a> 510 ### func \(\*BridgeClient\) [MintWZCN](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge.go#L490>) 511 512 ```go 513 func (b *BridgeClient) MintWZCN(ctx context.Context, payload *ethereum.MintPayload) (*types.Transaction, error) 514 ``` 515 516 MintWZCN Mint ZCN tokens on behalf of the 0ZCN client payload: received from authorizers 517 518 <a name="BridgeClient.MintZCN"></a> 519 ### func \(\*BridgeClient\) [MintZCN](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge.go#L589>) 520 521 ```go 522 func (b *BridgeClient) MintZCN(ctx context.Context, payload *zcnsc.MintPayload) (string, error) 523 ``` 524 525 MintZCN mints ZCN tokens after receiving proof\-of\-burn of WZCN tokens 526 527 <a name="BridgeClient.NFTConfigGetAddress"></a> 528 ### func \(\*BridgeClient\) [NFTConfigGetAddress](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge.go#L315>) 529 530 ```go 531 func (b *BridgeClient) NFTConfigGetAddress(ctx context.Context, key string) (string, string, error) 532 ``` 533 534 535 536 <a name="BridgeClient.NFTConfigGetUint256"></a> 537 ### func \(\*BridgeClient\) [NFTConfigGetUint256](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge.go#L270>) 538 539 ```go 540 func (b *BridgeClient) NFTConfigGetUint256(ctx context.Context, key string, keyParam ...int64) (string, int64, error) 541 ``` 542 543 544 545 <a name="BridgeClient.NFTConfigSetAddress"></a> 546 ### func \(\*BridgeClient\) [NFTConfigSetAddress](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge.go#L292>) 547 548 ```go 549 func (b *BridgeClient) NFTConfigSetAddress(ctx context.Context, key, address string) (*types.Transaction, error) 550 ``` 551 552 553 554 <a name="BridgeClient.NFTConfigSetUint256"></a> 555 ### func \(\*BridgeClient\) [NFTConfigSetUint256](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge.go#L244>) 556 557 ```go 558 func (b *BridgeClient) NFTConfigSetUint256(ctx context.Context, key string, value int64) (*types.Transaction, error) 559 ``` 560 561 NFTConfigSetUint256 call setUint256 method of NFTConfig contract 562 563 <a name="BridgeClient.NFTConfigSetUint256Raw"></a> 564 ### func \(\*BridgeClient\) [NFTConfigSetUint256Raw](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge.go#L249>) 565 566 ```go 567 func (b *BridgeClient) NFTConfigSetUint256Raw(ctx context.Context, key common.Hash, value int64) (*types.Transaction, error) 568 ``` 569 570 571 572 <a name="BridgeClient.QueryEthereumBurnEvents"></a> 573 ### func \(\*BridgeClient\) [QueryEthereumBurnEvents](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/authorizers_query.go#L112>) 574 575 ```go 576 func (b *BridgeClient) QueryEthereumBurnEvents(startNonce string) ([]*ethereum.BurnEvent, error) 577 ``` 578 579 QueryEthereumBurnEvents gets ethereum burn events 580 581 <a name="BridgeClient.QueryEthereumMintPayload"></a> 582 ### func \(\*BridgeClient\) [QueryEthereumMintPayload](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/authorizers_query.go#L50>) 583 584 ```go 585 func (b *BridgeClient) QueryEthereumMintPayload(zchainBurnHash string) (*ethereum.MintPayload, error) 586 ``` 587 588 QueryEthereumMintPayload gets burn ticket and creates mint payload to be minted in the Ethereum chain zchainBurnHash \- Ethereum burn transaction hash 589 590 <a name="BridgeClient.QueryZChainMintPayload"></a> 591 ### func \(\*BridgeClient\) [QueryZChainMintPayload](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/authorizers_query.go#L169>) 592 593 ```go 594 func (b *BridgeClient) QueryZChainMintPayload(ethBurnHash string) (*zcnsc.MintPayload, error) 595 ``` 596 597 QueryZChainMintPayload gets burn ticket and creates mint payload to be minted in the ZChain ethBurnHash \- Ethereum burn transaction hash 598 599 <a name="BridgeClient.RemoveEthereumAuthorizer"></a> 600 ### func \(\*BridgeClient\) [RemoveEthereumAuthorizer](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge.go#L134>) 601 602 ```go 603 func (b *BridgeClient) RemoveEthereumAuthorizer(ctx context.Context, address common.Address) (*types.Transaction, error) 604 ``` 605 606 RemoveEthereumAuthorizer Removes authorizer from Ethereum bridge. Only contract deployer can call this method 607 608 <a name="BridgeClient.ResetUserNonceMinted"></a> 609 ### func \(\*BridgeClient\) [ResetUserNonceMinted](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge.go#L467>) 610 611 ```go 612 func (b *BridgeClient) ResetUserNonceMinted(ctx context.Context) (*types.Transaction, error) 613 ``` 614 615 ResetUserNonceMinted Resets nonce for a specified Ethereum address 616 617 <a name="BridgeClient.SignWithEthereumChain"></a> 618 ### func \(\*BridgeClient\) [SignWithEthereumChain](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge.go#L419>) 619 620 ```go 621 func (b *BridgeClient) SignWithEthereumChain(message string) ([]byte, error) 622 ``` 623 624 SignWithEthereumChain signs the digest with Ethereum chain signer taking key from the current user key storage 625 626 <a name="BridgeClient.SwapETH"></a> 627 ### func \(\*BridgeClient\) [SwapETH](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge.go#L739>) 628 629 ```go 630 func (b *BridgeClient) SwapETH(ctx context.Context, source uint64, target uint64) (*types.Transaction, error) 631 ``` 632 633 SwapETH provides opportunity to perform zcn token swap operation using ETH as source token. 634 635 <a name="BridgeClient.SwapUSDC"></a> 636 ### func \(\*BridgeClient\) [SwapUSDC](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge.go#L768>) 637 638 ```go 639 func (b *BridgeClient) SwapUSDC(ctx context.Context, source uint64, target uint64) (*types.Transaction, error) 640 ``` 641 642 SwapUSDC provides opportunity to perform zcn token swap operation using USDC as source token. 643 644 <a name="BridgeClient.VerifyZCNTransaction"></a> 645 ### func \(\*BridgeClient\) [VerifyZCNTransaction](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge.go#L414>) 646 647 ```go 648 func (b *BridgeClient) VerifyZCNTransaction(ctx context.Context, hash string) (transaction.Transaction, error) 649 ``` 650 651 VerifyZCNTransaction verifies 0CHain transaction 652 653 <a name="BridgeSDKConfig"></a> 654 ## type [BridgeSDKConfig](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/config.go#L34-L40>) 655 656 657 658 ```go 659 type BridgeSDKConfig struct { 660 LogLevel *string 661 LogPath *string 662 ConfigChainFile *string 663 ConfigDir *string 664 Development *bool 665 } 666 ``` 667 668 <a name="DetailedAccount"></a> 669 ## type [DetailedAccount](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/keystore.go#L16-L20>) 670 671 DetailedAccount describes detailed account 672 673 ```go 674 type DetailedAccount struct { 675 EthereumAddress, 676 PublicKey, 677 PrivateKey accounts.Account 678 } 679 ``` 680 681 <a name="EthereumBurnEvents"></a> 682 ## type [EthereumBurnEvents](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/authorizer_response.go#L28-L35>) 683 684 EthereumBurnEvents represents burn events returned by authorizers 685 686 ```go 687 type EthereumBurnEvents struct { 688 AuthorizerID string `json:"authorizer_id,omitempty"` 689 BurnEvents []struct { 690 Nonce int64 `json:"nonce"` 691 Amount int64 `json:"amount"` 692 TransactionHash string `json:"transaction_hash"` 693 } `json:"burn_events"` 694 } 695 ``` 696 697 <a name="EthereumBurnEvents.Data"></a> 698 ### func \(\*EthereumBurnEvents\) [Data](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/authorizer_response.go#L106>) 699 700 ```go 701 func (r *EthereumBurnEvents) Data() interface{} 702 ``` 703 704 705 706 <a name="EthereumBurnEvents.Error"></a> 707 ### func \(\*EthereumBurnEvents\) [Error](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/authorizer_response.go#L102>) 708 709 ```go 710 func (r *EthereumBurnEvents) Error() error 711 ``` 712 713 714 715 <a name="EthereumBurnEvents.GetAuthorizerID"></a> 716 ### func \(\*EthereumBurnEvents\) [GetAuthorizerID](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/authorizer_response.go#L94>) 717 718 ```go 719 func (r *EthereumBurnEvents) GetAuthorizerID() string 720 ``` 721 722 723 724 <a name="EthereumBurnEvents.SetAuthorizerID"></a> 725 ### func \(\*EthereumBurnEvents\) [SetAuthorizerID](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/authorizer_response.go#L98>) 726 727 ```go 728 func (r *EthereumBurnEvents) SetAuthorizerID(id string) 729 ``` 730 731 732 733 <a name="EthereumClient"></a> 734 ## type [EthereumClient](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/config.go#L43-L47>) 735 736 EthereumClient describes Ethereum JSON\-RPC client generealized interface 737 738 ```go 739 type EthereumClient interface { 740 bind.ContractBackend 741 742 ChainID(ctx context.Context) (*big.Int, error) 743 } 744 ``` 745 746 <a name="GasEstimationRequest"></a> 747 ## type [GasEstimationRequest](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge_helper.go#L22-L26>) 748 749 GasEstimationRequest describes request used for Alchemy enhanced JSON\-RPC API. 750 751 ```go 752 type GasEstimationRequest struct { 753 From string `json:"from"` 754 To string `json:"to"` 755 Value string `json:"value"` 756 } 757 ``` 758 759 <a name="GasPriceEstimationResult"></a> 760 ## type [GasPriceEstimationResult](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/bridge_helper.go#L29-L31>) 761 762 GasPriceEstimationResult represents result of the gas price estimation operation execution. 763 764 ```go 765 type GasPriceEstimationResult struct { 766 Value float64 `json:"value"` 767 } 768 ``` 769 770 <a name="JobError"></a> 771 ## type [JobError](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/authorizer_response.go#L23-L25>) 772 773 JobError result of internal request wrapped in authorizer job 774 775 ```go 776 type JobError struct { 777 // contains filtered or unexported fields 778 } 779 ``` 780 781 <a name="JobError.MarshalJSON"></a> 782 ### func \(\*JobError\) [MarshalJSON](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/authorizer_response.go#L62>) 783 784 ```go 785 func (e *JobError) MarshalJSON() ([]byte, error) 786 ``` 787 788 789 790 <a name="JobError.UnmarshalJSON"></a> 791 ### func \(\*JobError\) [UnmarshalJSON](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/authorizer_response.go#L57>) 792 793 ```go 794 func (e *JobError) UnmarshalJSON(buf []byte) error 795 ``` 796 797 798 799 <a name="JobResult"></a> 800 ## type [JobResult](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/authorizer_response.go#L12-L21>) 801 802 JobResult = Authorizer task result, it wraps actual result of the query inside authorizer 803 804 ```go 805 type JobResult interface { 806 // Error = Status of Authorizer job on authorizer server 807 Error() error 808 // Data returns the actual result 809 Data() interface{} 810 // SetAuthorizerID Assigns authorizer ID to the Job 811 SetAuthorizerID(ID string) 812 // GetAuthorizerID returns authorizer ID 813 GetAuthorizerID() string 814 } 815 ``` 816 817 <a name="JobStatus"></a> 818 ## type [JobStatus](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/authorizer_response.go#L10>) 819 820 JobStatus = Ethereum transaction status 821 822 ```go 823 type JobStatus uint 824 ``` 825 826 <a name="KeyStore"></a> 827 ## type [KeyStore](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/keystore.go#L23-L28>) 828 829 KeyStore is a wrapper, which exposes Ethereum KeyStore methods used by DEX bridge. 830 831 ```go 832 type KeyStore interface { 833 Find(accounts.Account) (accounts.Account, error) 834 TimedUnlock(accounts.Account, string, time.Duration) error 835 SignHash(account accounts.Account, hash []byte) ([]byte, error) 836 GetEthereumKeyStore() *keystore.KeyStore 837 } 838 ``` 839 840 <a name="NewKeyStore"></a> 841 ### func [NewKeyStore](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/keystore.go#L35>) 842 843 ```go 844 func NewKeyStore(path string) KeyStore 845 ``` 846 847 NewKeyStore creates new KeyStore wrapper instance 848 849 <a name="ProofEthereumBurn"></a> 850 ## type [ProofEthereumBurn](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/authorizer_response.go#L38-L44>) 851 852 ProofEthereumBurn Authorizer returns this type for Ethereum transaction 853 854 ```go 855 type ProofEthereumBurn struct { 856 TxnID string `json:"ethereum_txn_id"` 857 Nonce int64 `json:"nonce"` 858 Amount int64 `json:"amount"` 859 ReceivingClientID string `json:"receiving_client_id"` // 0ZCN address 860 Signature string `json:"signature"` 861 } 862 ``` 863 864 <a name="ProofZCNBurn"></a> 865 ## type [ProofZCNBurn](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/authorizer_response.go#L47-L54>) 866 867 ProofZCNBurn Authorizer returns this type for ZCN transaction 868 869 ```go 870 type ProofZCNBurn struct { 871 AuthorizerID string `json:"authorizer_id,omitempty"` 872 TxnID string `json:"0chain_txn_id"` 873 To string `json:"to"` 874 Nonce int64 `json:"nonce"` 875 Amount int64 `json:"amount"` 876 Signature []byte `json:"signature"` 877 } 878 ``` 879 880 <a name="ProofZCNBurn.Data"></a> 881 ### func \(\*ProofZCNBurn\) [Data](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/authorizer_response.go#L122>) 882 883 ```go 884 func (r *ProofZCNBurn) Data() interface{} 885 ``` 886 887 888 889 <a name="ProofZCNBurn.Error"></a> 890 ### func \(\*ProofZCNBurn\) [Error](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/authorizer_response.go#L118>) 891 892 ```go 893 func (r *ProofZCNBurn) Error() error 894 ``` 895 896 897 898 <a name="ProofZCNBurn.GetAuthorizerID"></a> 899 ### func \(\*ProofZCNBurn\) [GetAuthorizerID](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/authorizer_response.go#L110>) 900 901 ```go 902 func (r *ProofZCNBurn) GetAuthorizerID() string 903 ``` 904 905 906 907 <a name="ProofZCNBurn.SetAuthorizerID"></a> 908 ### func \(\*ProofZCNBurn\) [SetAuthorizerID](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/authorizer_response.go#L114>) 909 910 ```go 911 func (r *ProofZCNBurn) SetAuthorizerID(id string) 912 ``` 913 914 915 916 <a name="WZCNBurnEvent"></a> 917 ## type [WZCNBurnEvent](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/authorizer_response.go#L67-L76>) 918 919 WZCNBurnEvent returned from burn ticket handler of: /v1/ether/burnticket/get 920 921 ```go 922 type WZCNBurnEvent struct { 923 // AuthorizerID Authorizer ID 924 AuthorizerID string `json:"authorizer_id,omitempty"` 925 // BurnTicket Returns burn ticket 926 BurnTicket *ProofEthereumBurn `json:"ticket,omitempty"` 927 // Err gives error of job on server side 928 Err *JobError `json:"err,omitempty"` 929 // Status gives job status on server side (authoriser) 930 Status JobStatus `json:"status,omitempty"` 931 } 932 ``` 933 934 <a name="WZCNBurnEvent.Data"></a> 935 ### func \(\*WZCNBurnEvent\) [Data](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/authorizer_response.go#L90>) 936 937 ```go 938 func (r *WZCNBurnEvent) Data() interface{} 939 ``` 940 941 942 943 <a name="WZCNBurnEvent.Error"></a> 944 ### func \(\*WZCNBurnEvent\) [Error](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/authorizer_response.go#L86>) 945 946 ```go 947 func (r *WZCNBurnEvent) Error() error 948 ``` 949 950 951 952 <a name="WZCNBurnEvent.GetAuthorizerID"></a> 953 ### func \(\*WZCNBurnEvent\) [GetAuthorizerID](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/authorizer_response.go#L78>) 954 955 ```go 956 func (r *WZCNBurnEvent) GetAuthorizerID() string 957 ``` 958 959 960 961 <a name="WZCNBurnEvent.SetAuthorizerID"></a> 962 ### func \(\*WZCNBurnEvent\) [SetAuthorizerID](<https://github.com/0chain/gosdk/blob/doc/initial/zcnbridge/authorizer_response.go#L82>) 963 964 ```go 965 func (r *WZCNBurnEvent) SetAuthorizerID(id string) 966 ``` 967 968 969 970 Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)