XDC Go SDK
XRC20 Token Integration
How to call functions in Go SDK?
CreateAccount() → string
Returns the Private Key.
CheckAddress(Private_key string) → string
Returns the Address User.
Name(Token_address string) → string
Returns the name of the token.
Symbol(Token_address string) → string
Returns the symbol of the token, usually a shorter version of the name.
Decimals(Token_address string) → uint8
Returns the number of decimals used to get its user representation. For example, if decimals equal 2, a balance of 505 tokens should be displayed to a user as 5,05 (505 / 10 ** 2).
Tokens usually opt for a value of 18, imitating the relationship between Ether and Wei.
Total_supply(Token_address string) → string
Returns the number of tokens in existence.
BalanceOf(Token_address string ,Owner_address string) → string
Returns the number of tokens owned by the account.
Allowance(Token_address string , Owner_address string , Spender_address string) → string
Returns the remaining number of tokens that the spender will be allowed to spend on behalf of the owner through transferFrom
. It is zero by default.
Approve_(Private_key string, Token_address string,sender_address string,Gas_Price string,Gas_Limit string,Amount string) -> string
Pass Private key, Token address, Spender address, Gas Price, Gas Limit. It will return a transaction hash.
XDCTransfer(Private_key string, To_Address string, Value_ string,gasLimit uint64) -> string
Moves XDC from the caller’s account to recipient. It will return a transaction hash.
TokenTransfer_(Private_key string, Token_address string, sender_address string,Gas_Price string, Gas_Limit string,Tokens_ string) -> string
Moves tokens from the caller’s account to the recipient. It will return a transaction hash.
FromTransfer_(Private_key string, Token_address string,sender_address string,Gas_Price string,Gas_Limit string,Amount string) -> string
Pass Private key, Token address, Spender address, Gas Price, Gas Limit and Amount. It will return a transaction hash.
IncreaseAllowance_(Private_key string, Token_address string,sender_address string,Gas_Price string,Gas_Limit string,Amount string) -> string
Automatically increases the allowance granted to spender by the caller.
DecreaseAllowance_(Private_key string,Token_address string,sender_address string,Gas_Price string, Gas_Limit string, Amount string) -> string
Automatically decreases the allowance granted to spender by the caller.
Example to call functions in Go SDK
Step 1: Clone git repo (go-xdc) in any folder and copy it.
Step 2: Go to that directory where your Golang saves. (go to your go folder).
Step 3: Find SRC in your go folder.
Step 4: Open SRC Folder and pasted your go-xdc.
Use like this in your main package.
XRC721 Token Integration
How to call functions in Go SDK?
OwnerOff_(tokenAddress string , TokenID string) → common.Address
Returns the owner's address.
IsApprovedForAll_(tokenAddress string ,owneraddress string, operatoraddress string) → bool
Returns the True or false.
Name_(tokenAddress string) → string
Returns the name of the token.
Symbol_(tokenAddress string) → string
Returns the symbol of the token, usually a shorter version of the name.
TokenURI_(tokenAddress string, TokenID string) → string
Return the Token URL.
TokenOfOwnerByIndex_(tokenAddress string, IndexNO string, OwnerAddress string) → string
Returns the symbol of the token, usually a shorter version of the name.
GetApproved_(tokenAddress string, TokenID string) → common.Address
Return True or False.
TotalSupply_(tokenAddress string) → string
Returns the number of tokens in existence.
BalanceOff_(tokenAddress string , Owneraddress string) → string
Returns the number of tokens owned by the account.
SupportInterface_(tokenAddress string, InterfaceID int) → bool
Return True or False.
Approve_(Private_key string , Token_address string,sender_address string,Gas_Price string,Gas_Limit string,TokenId string ) -> string
Pass Private key, Token address, Sender address, Gas Price, Gas Limit and Token id. It will return a transaction hash.
SafeTransfer_(Private_key string,Token_address string ,sender_address string ,Gas_Price string ,Gas_Limit string , TokenId string) -> string
Used for the safe transfer of token ownership.
TransferFrom_(Private_key string ,Token_address string ,sender_address string, Gas_Price string,Gas_Limit string ,TokenId string) -> string
Used to transfer token ownership.
Setapprovalforall_(Private_key string ,Token_address string,sender_address string,Gas_Price string,Gas_Limit string,boolvalue string) -> string
Pass Private key, Token address, Sender address, Gas Price, Gas Limit and Bool value. It will return a transaction hash.
NOTE - pass boolvalue in only 0 or 1.
0- False
1-True
Example to call functions in Go SDK
Step1: Clone git repo (XDC) in any folder and copy it.
Step2: Go to that directory where your Golang is saved (go to your Go folder).
Step3: Find SRC in your Go folder.
Step4: Open SRC Folder and paste your XDC.
Use it in your main package as:
Last updated