# SPL

Bulk SLP With 7H

i

```
mint,
associatedAddr,
sender.publicKey,
MAX_TOKENS,
TOKEN_DECIMALS
```

); 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 });

```
  await Promise.all(
    txChunk.map(async (tx: Transaction, i: number) => {
      logger.debug(`Sending transaction ${i + 1}`);

      // feed transaction into TransactionWrapper
      const wrapper = await TransactionWrapper.create({
        connection: conn,
        transaction: tx,
        signer: sender.publicKey,
      }).addBlockhashAndFeePayer(sender.publicKey);

      // sign the transaction
      logger.debug(`Signing transaction ${i + 1}`);
      const signedTx = await wrapper.sign({
        signer: sender as Signer,
      });

      // send and confirm the transaction
      logger.debug(`Sending transaction ${i + 1}`);
      const transferSig = await wrapper.sendAndConfirm({
        serialisedTx: signedTx.serialize(),
        commitment: COMMITMENT,
      });
      logger.debug("Transaction sent:", transferSig.toString());
    })
  );
  await sleep(DELAY_BETWEEN_CHUNKS_MS);
}
```

}

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}`);

```
// split addresses into chunks of CHUNK_SIZE
const chunks = chunk(receivers, CHUNK_SIZE);
const balances: {
  balance: number;
  address: string;
}[] = [];
for (let i = 0; i < chunks.length; i++) {
  const chunk = chunks[i];
  logger.debug(
    `Fetching balances for chunk ${i + 1} with ${chunk.length} addresses`
  );

  // cycle to new connection to avoid rate limiting
  let conn = cm.connSync({ changeConn: true });

  // fetch balances
  const results = await Promise.all(
    chunk.map(async (receiver: Keypair) => {
      const balance = await conn.getBalance(receiver.publicKey, COMMITMENT);
      logger.debug(
        `Balance of ${receiver.publicKey.toBase58()}: ${balance}`
      );
      return {
        balance,
        address: receiver.publicKey.toBase58(),
      };
    })
  );

  // add results to balances
  balances.push(...results);
  await sleep(DELAY_BETWEEN_CHUNKS_MS);
}

const totalBalance = balances.reduce((acc, curr) => acc + curr.balance, 0);
const numberWithNoBalance = balances.filter((b) => b.balance === 0).length;
const numberWithBalance = balances.filter((b) => b.balance > 0).length;
logger.debug(`Total amount sent: ${totalBalance}`);
logger.debug(`Number of addresses with no balance: ${numberWithNoBalance}`);
logger.debug(`Number of addresses with balance: ${numberWithBalance}`);
```

} })();

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:

<table><thead><tr><th width="214">Field</th><th width="311">Description</th><th width="80">Type</th><th>Optional</th></tr></thead><tbody><tr><td>identifier</td><td>A unique marker distinguishing the SPL contract within 7H. Generated upon successful contract deployment by the 7H platform.</td><td>string</td><td>No</td></tr><tr><td>address</td><td>An exclusive tag identifying the SPL contract within the Polygon blockchain realm. Generated upon successful contract deployment by the 7H platform.</td><td>string</td><td>No</td></tr><tr><td>title</td><td>The designated name of the token contract.</td><td>string</td><td>No</td></tr><tr><td>notation</td><td>The chosen symbol representing the token contract.</td><td>string</td><td>No</td></tr><tr><td>restrict_transfers</td><td>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.</td><td>boolean</td><td>Yes</td></tr><tr><td>authorized_transfers</td><td>The catalog of wallet addresses permitted to initiate token transfers. Applicable only when transfer restrictions are in effect. Default is an empty list.</td><td>[string]</td><td>Yes</td></tr></tbody></table>

7H SPL API Procedures The 7H API extends the subsequent methods for the formulation and governance of SPL tokens:

1. **Create New** 7H **Token:**
   * **Method:** POST
   * **Description:** Establish a new SPL token through the provision of specified name, symbol, and parameters.
2. **Retrieve** 7H **Tokens:**
   * **Method:** GET
   * **Description:** Acquire a comprehensive list of all SPL contracts affiliated with the 7H organization.
3. **Modify** 7H **Token Configuration:**
   * **Method:** PATCH
   * **Description:** Oversee and adjust various configurations on the SPL contract, including transfer restrictions.
4. **Generate** 7H **Token Units:**
   * **Method:** POST
   * **Description:** Create additional units of SPL tokens and allocate them to a designated wallet address.
5. **Conduct** 7H **Token Transfer:**
   * **Method:** POST
   * **Description:** Execute a transfer of SPL tokens from one wallet address to another.
