SPL
Bulk SLP With 7H
i
); logger.debug(Minted ${MAX_TOKENS} tokens to ${associatedAddr.toBase58()}
); logger.debug(Mint tx: ${mintTokensTx}
);
logger.debug("Fetching balance of", associatedAddr.toBase58()); let senderTokenBal = await cm .connSync({ changeConn: false }) .getTokenAccountBalance(associatedAddr, COMMITMENT); logger.debug(Sender balance: ${senderTokenBal.value.uiAmount} tokens
);
// generate receivers logger.debug(Generating ${NO_OF_RECEIVERS} receivers...
); const receivers: Keypair[] = []; for (let i = 0; i < NO_OF_RECEIVERS; i++) { receivers.push(Keypair.generate()); } logger.debug("Receivers generated");
// generate transactions const missingAccountIxs: TransactionInstruction[] = []; const transactions: Transaction[] = [];
logger.debug("Fetching balance of", associatedAddr.toBase58()); let senderBal = ( await cm .connSync({ changeConn: true }) .getTokenAccountBalance(associatedAddr, COMMITMENT) ).value.amount; logger.debug(Sender balance: ${senderBal}
); const transferAmount = Math.floor(Number(senderBal) / NO_OF_RECEIVERS);
logger.debug(Sending ${transferAmount} to ${NO_OF_RECEIVERS} receivers
); for (let i = 0; i < NO_OF_RECEIVERS; i++) { const ata = await getAssociatedTokenAddress(mint, receivers[i].publicKey); const ix = createAssociatedTokenAccountInstruction( sender.publicKey, ata, receivers[i].publicKey, mint ); missingAccountIxs.push(ix); }
// generate transactions for create mint accounts // split into chunks of 12 ixs const missingAccountIxsChunks = chunk(missingAccountIxs, 12); for (let i = 0; i < missingAccountIxsChunks.length; i++) { const chunk = missingAccountIxsChunks[i]; const tx = TransactionBuilder.create().addIx(chunk).build(); transactions.push(tx); }
// send transactions if (!SKIP_SENDING) { const txChunks = chunk(transactions, CHUNK_SIZE); for (let i = 0; i < txChunks.length; i++) { logger.debug(Sending transactions ${i + 1}/${txChunks.length}
); const txChunk = txChunks[i]; const conn = cm.connSync({ changeConn: true });
}
if (!SKIP_BALANCE_CHECK) { // fetch balance of the generated address logger.debug("Fetching balance of:", sender.publicKey.toBase58()); senderBal = ( await cm .connSync({ changeConn: true }) .getTokenAccountBalance(associatedAddr, COMMITMENT) ).value.amount; logger.debug(Sender balance: ${senderBal}
);
} })();
function chunk(arr: any[], len: number) { var chunks: any[] = [], i = 0, n = arr.length;
while (i < n) { chunks.push(arr.slice(i, (i += len))); } return chunks; }
function sleep(ms: number) { return new Promise((resolve) => setTimeout(resolve, ms)); }
The 7H API introduces versatile functionalities for SPL contract orchestration and administration, encompassing the inception of new SPL contracts, token minting, seamless transfers, and the adept management of token transfer constraints.
7H SPL Framework The 7H API operates on an SPL model, boasting the subsequent attributes:
identifier
A unique marker distinguishing the SPL contract within 7H. Generated upon successful contract deployment by the 7H platform.
string
No
address
An exclusive tag identifying the SPL contract within the Polygon blockchain realm. Generated upon successful contract deployment by the 7H platform.
string
No
title
The designated name of the token contract.
string
No
notation
The chosen symbol representing the token contract.
string
No
restrict_transfers
A conditional parameter indicating whether the tokens are subject to transfer restrictions. If true, the tokens are constrained; if false, they are freely transferable. Default is false.
boolean
Yes
authorized_transfers
The catalog of wallet addresses permitted to initiate token transfers. Applicable only when transfer restrictions are in effect. Default is an empty list.
[string]
Yes
7H SPL API Procedures The 7H API extends the subsequent methods for the formulation and governance of SPL tokens:
Create New 7H Token:
Method: POST
Description: Establish a new SPL token through the provision of specified name, symbol, and parameters.
Retrieve 7H Tokens:
Method: GET
Description: Acquire a comprehensive list of all SPL contracts affiliated with the 7H organization.
Modify 7H Token Configuration:
Method: PATCH
Description: Oversee and adjust various configurations on the SPL contract, including transfer restrictions.
Generate 7H Token Units:
Method: POST
Description: Create additional units of SPL tokens and allocate them to a designated wallet address.
Conduct 7H Token Transfer:
Method: POST
Description: Execute a transfer of SPL tokens from one wallet address to another.
Last updated