1.1.2 • Published 1 year ago

zoidpay-blockchain-helpers v1.1.2

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Blockchain helper

What does it do?

Facilitates the Elrond blockchain transactions for ESDT, SFT, NFT and METAESDT.

How to use?

Instantiate the Elrond class like follows:

const elrond = new Elrond({
    address: "erd1lv6eyd8mwprssw7qcx5zpghggcd95wxas27pwhyygsx75c5we5zskn5k8e", // your address
    password: "Azerty.2023", // your password
    jsonWallet: walletObject, // your wallet object
    networkProvider: "https://devnet-api.multiversx.com" // network you want to use
});

The password and walletObject fields are optional, however, if you do not provide them when instantiating the Elrond object, you will not be able to sign and send the transaction with the helper functions signTransaction() and sendTransaction().

Build transaction

Create your payload object, depending on what transaction you want to make. For example, if you wanted to make a token transfer, the payload would look like this:

const createNFTpayload = {
    tokenTicker: "MMM-e4f01d",
    valueToTransfer: 100,
    addressToSendTo: "erd1lv6eyd8mwprssw7qcx5zpghggcd95wxas27pwhyygsx75c5we5zskn5k8e"
   }
let tx = await elrond.buildTransaction({
    transactionCategory: TransactionCategory.NFT,
    transactionType: NFTFunctions.ESDTNFTCreate,
    operationsData: createNFTpayload
});

Observation:

  • when the data payload contains an address it must be already converted from a bech32 to hex format when placed as input. Always look for this type of format to input: fb359234fb7047083bc0c1a820a2e8461a5a38dd82bc175c84440dea628ecd05

      Example of transaction:
      ```
                  tx =  new Transaction({
                  gasLimit: builtData.gasLimit,
                  sender: new Address(this.address), ===== Accepted format of address: ```erd1lv6eyd8mwprssw7qcx5zpghggcd95wxas27pwhyygsx75c5we5zskn5k8e```
                  receiver: new Address(builtData.actionAddress), ===== Accepted of address format: ```erd1lv6eyd8mwprssw7qcx5zpghggcd95wxas27pwhyygsx75c5we5zskn5k8e```
                  value: builtData.value,
                  chainID: chainId,
                  nonce: nonce,
                  data: new TransactionPayload(builtData.data) ===== Accepted format of address here: ```fb359234fb7047083bc0c1a820a2e8461a5a38dd82bc175c84440dea628ecd05```
              });
      ```

Sign transaction

elrond.signTransaction(tx);

Send signed transaction

elrond.sendTansaction(tx, await elrond.establishConnection());

Available functions

ESDTNFTSFTMetaESDT
transferissueNonFungibleissueSemiFungibleregisterMetaESDT
localMintsetSpecialRolesetSpecialRolechangeSFTToMetaESDT
localBurnESDTNFTCreateESDTNFTCreate
issuetransferNFTCreateRoleESDTNFTBurn
pausestopNFTCreateESDTNFTAddQuantity
unPauseESDTNFTUpdateAttributes
freezeESDTNFTAddURI
unFreezefreezeSingleNFT
setSpecialRoleunFreezeSingleNFT
unSetSpecialRolewipeSingleNFT
controlChangesESDTNFTTransfer
transferOwnership
1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago