XDC .Net SDK

XRC20 Token Integration

Get XRC20 token-related information from XDCSDKLib DLL by following the steps given below:

  1. Install the latest version of Visual Studio with .Net core v3.1 in Windows Operating System.

  2. Add all the supporting DLL files into the .Net core new project by adding project references. The DLL files:

    1. Nethereum.Web3.dll

    2. XDCSDKLib.dll

    3. BouncyCastle.Crypto.dll

    4. Common.Logging.Core.dll

    5. Nethereum.ABI.dll

    6. Nethereum.Accounts.dll

    7. Nethereum.BlockchainProcessing.dll

    8. Nethereum.Contracts.dll

    9. Nethereum.HdWallet.dll

    10. Nethereum.Hex.dll

    11. Nethereum.JsonRpc.Client.dll

    12. Nethereum.JsonRpc.RpcClient.dll

    13. Nethereum.KeyStore.dll

    14. Nethereum.Model.dll

    15. Nethereum.RLP.dll

    16. Nethereum.RPC.dll

    17. Nethereum.Signer.dll

    18. Nethereum.StandardTokenEIP20.dll

    19. Nethereum.Util.dll

    20. Newtonsoft.Json.dll

    21. ERC721ContractLibrary.dll

  3. We pushed all the above-listed DLLs into the branch “XDC-SDK-Supported-DLL’’.

Getting Started

Create an instance of the XRC20 token:

using XDCSDKLib;
IXRC20Token XRC20Token = new XRC20Token();

Read methods

name

var name= await  XRC20Token.GetTokenName(“contractAddress”, “BlockchainNetworkUrl”);

symbol

var symbol=  await XRC20Token. GetSymbol (“contractAddress”, “BlockchainNetworkUrl”);

decimal

var decimal=  await XRC20Token. GetDecimal (“contractAddress”, “BlockchainNetworkUrl”);

TotalSupply

var supply=  await XRC20Token. GetTotalSupply (“contractAddress”, “BlockchainNetworkUrl”);

balanceOf

var balanceOf=  await XRC20Token. GetBalanceOf (“contractAddress”, “BlockchainNetworkUrl”,”ownerAdddress”);

Allowance

var allowance=  await XRC20Token. GetAllowance (“contractAddress”, ”ownerAdddress”,“BlockchainNetworkUrl”,” addressSpender”);

Write Methods

Approve

var approve=  await XRC20Token. Approve(“contractAddress”, ” addressSpender”,” allowanceValue”,“BlockchainNetworkUrl”,”OwnerprivateKey”);

TransferFrom

var transferFrom=  await XRC20Token. TransferFrom(“contractAddress”, ”OwnerAddress”,”addressTo”,” allowanceValue”,“BlockchainNetworkUrl”,”SpenderPrivateKey”);

Transfer

var transfer=  await XRC20Token. Transfer(“contractAddress”,”addressTo”,”tokenValue”,“BlockchainNetworkUrl”,”OwnerprivateKey”);

IncreaseAllowance

var allowance=  await XRC20Token. GetIncreasesAllowance (“contractAddress”,”OwnerAddress”,”addressSpender”,”increaseAllowance”,“BlockchainNetworkUrl”,”SpenderPrivateKey”);

DecreaseAllowance

var allowance=  await XRC20Token. GetDecreaseAllowance (“contractAddress”,”OwnerAddress”,”addressSpender”,”decreasesAllowance”,“BlockchainNetworkUrl”,”SpenderPrivateKey”);

TransferXdcAmmount

var XdcAmmount=  await XRC20Token. TransferXdcAmmount (“toAddress”,”amount”,“BlockchainNetworkUrl”,”ownerPrivateKey”);

XRC721 Token Integration

Get XRC721 token-related information from XDCSDKLib DLL by following the steps given below:

Getting Started

Create an instance of the XRC20 token:

Using XDCSDKLib;
IXRC721Token xRC721Token = new XRC721Token();

Read Methods

name

var name=  await xRC721Token.GetTokenName (“contractAddress”, “BlockchainNetworkUrl”);

symbol

var symbol=  await xRC721Token. GetSymbol (“contractAddress”, “BlockchainNetworkUrl”);

decimal

var decimal=  await xRC721Token. GetDecimal (“contractAddress”, “BlockchainNetworkUrl”);

TotalSupply

var supply= await xRC721Token. GetTotalSupply (“contractAddress”, “BlockchainNetworkUrl”);

balanceOf

var balanceOf=  await xRC721Token. GetBalanceOf (“contractAddress”, “ownerAdddress”, “BlockchainNetworkUrl”);

tokenURI

var tokenURI=  await xRC721Token. GetTokenURI (“contractAddress”, ”tokenId”,“BlockchainNetworkUrl”);

ownerOf

var ownerOf=  await xRC721Token. GetOwnerOf (“contractAddress”, ”tokenId”,“BlockchainNetworkUrl”);

tokenOwnerbyIndex

var tokenOwnerbyIndex =  await xRC721Token. GetTokenOfOwnerByIndex (“contractAddress”, ”ownerAddress”,”Index”,“BlockchainNetworkUrl”);

TokenByIndex

var tokenIndex =  await xRC721Token. GetTokenByIndex (“contractAddress”, ” tokenByIndex”,“BlockchainNetworkUrl”);

GetApproved

var getApproved=  await xRC721Token. GetApproved (“contractAddress”, ”tokenId”,“BlockchainNetworkUrl”);

supportsInterface

var supportsInterface=  await xRC721Token. SupportsInterface (“contractAddress”, byte[] InterfaceId ,“BlockchainNetworkUrl”);

Write Methods

approve

var approve=  await xRC721Token. Approve (“contractAddress”, “addresTo”,“tokenId”“BlockchainNetworkUrl”,”ownerPrivateKey”);

SetApprovalforAll

var setApproveAll=  await xRC721Token. SetApprovalforAll (“contractAddress”, “addresTo”,approved “BlockchainNetworkUrl”,”ownerPrivateKey”);

IsApprovalforAll

var IsApprovalforAll=  await xRC721Token. IsApprovalforAll (“contractAddress”, “OwnerAddress”,“operatorAddress”,“BlockchainNetworkUrl”,”ownerPrivateKey”);

Transferfrom

var tranFrom=  await xRC721Token. TransferFrom (“contractAddress”, “addresTo”,“tokenId”“BlockchainNetworkUrl”,”ownerPrivateKey”);

SafeTransferFrom

var SafeTransferFrom =  await xRC721Token. SafeTransferFrom (“contractAddress”,” fromAddress”,“addresTo”,“tokenId”“BlockchainNetworkUrl”,”ownerPrivateKey”);

Create an XRC account

Create the XRC account using the following code:

IAccount account=new Account();

account.CreateAccount(“password”,”workingDirectory”);

var privateKey = account.PrivateKey;

var accountAddress= account.AccountAddress;

Private Key can also be accessed from the working directory that is saved in the system by the following method:

Var privateKey= account.GetPrivateKey(“nameoffile”,”workingdirectory”,”password”);

How to Publish the XDCSDKWebApi into the server?

  1. Install the SDK .net core 3.1 version on the server and publish the supported DLL files into the virtual directory of the server. We pushed all the supported DLLs for publishing the XDCSDKWebAPI into the branch PublishDllForXDCWebApi.

  2. As per requirements, change the URL of BlockNetworkChain into the appsettings.json file.

"XDCSDKUrl": {
"Url": "
https://rpc.apothem.network/
"
}

Hardware requirements:

  • Operating system: Windows 10 or upper version, windows server latest.

  • Memory (RAM): minimum 8 GB

  • Processor: Core I3 or above.

Last updated