async sendTransaction(transaction) {
          await this.call("chain.submit_transaction", { transaction });
          const startTime = Date.now() + 10000;
          return {
            wait: async (type = "byTransactionId") => {
              // sleep some seconds before it gets mined
              await sleep(startTime - Date.now() - 1000);
              if (type === "byTransactionId") {
                for (let i = 0; i < 30; i += 1) {
                  await sleep(1000);
                  const { transactions } = await this.getTransactionsById([
                    transaction.id,
                  ]);
                  if (
                    transactions &&
                    transactions[0] &&
                    transactions[0].containing_blocks
                  )
                    return transactions[0].containing_blocks[0];
                }
                throw new Error(`Transaction not mined after 40 seconds`);
              }
              // byBlock
              let blockNumber = 0;
              let iniBlock = 0;
              for (let i = 0; i < 90; i += 1) {
                await sleep(1000);
                const { head_topology: headTopology } =
                  await this.getHeadInfo();
                if (i === 0) {
                  blockNumber = Number(headTopology.height);
                  iniBlock = blockNumber;
                } else {
                  blockNumber += 1;
                }
                if (blockNumber > Number(headTopology.height)) continue;
                const [block] = await this.getBlocks(
                  blockNumber,
                  1,
                  headTopology.id
                );
                if (
                  !block ||
                  !block.block ||
                  !block.block_id ||
                  !block.block.transactions
                )
                  continue;
                const tx = block.block.transactions.find(
                  (t) => t.id === transaction.id
                );
                if (tx) return blockNumber.toString();
              }
              throw new Error(
                `Transaction not mined from block ${iniBlock} to ${blockNumber}`
              );
            },
          };
        }
/**
         * Function to call "chain.submit_transaction" to send a signed
         * transaction to the blockchain. It returns an object with the async
         * function "wait", which can be called to wait for the
         * transaction to be mined.
         * @param transaction - Signed transaction
         * @example
         * ```ts
         * const { transactionResponse } = await provider.sendTransaction({
         *   id: "1220...",
         *   active: "...",
         *   signatureData: "...",
         * });
         * console.log("Transaction submitted to the mempool");
         * // wait to be mined
         * const blockId = await transactionResponse.wait();
         * console.log("Transaction mined")
         * ```
         */
Function to call "chain.submit_transaction" to send a signed
transaction to the blockchain. It returns an object with the async
function "wait", which can be called to wait for the
transaction to be mined.
Function to call " chain . submit_transaction " to send a signed transaction to the blockchain . It returns an object with the async function " wait " which can be called to wait for the transaction to be mined .
async sendTransaction(transaction) {
          await this.call("chain.submit_transaction", { transaction });
          const startTime = Date.now() + 10000;
          return {
            wait: async (type = "byTransactionId") => {
              await sleep(startTime - Date.now() - 1000);
              if (type === "byTransactionId") {
                for (let i = 0; i < 30; i += 1) {
                  await sleep(1000);
                  const { transactions } = await this.getTransactionsById([
                    transaction.id,
                  ]);
                  if (
                    transactions &&
                    transactions[0] &&
                    transactions[0].containing_blocks
                  )
                    return transactions[0].containing_blocks[0];
                }
                throw new Error(`Transaction not mined after 40 seconds`);
              }
              let blockNumber = 0;
              let iniBlock = 0;
              for (let i = 0; i < 90; i += 1) {
                await sleep(1000);
                const { head_topology: headTopology } =
                  await this.getHeadInfo();
                if (i === 0) {
                  blockNumber = Number(headTopology.height);
                  iniBlock = blockNumber;
                } else {
                  blockNumber += 1;
                }
                if (blockNumber > Number(headTopology.height)) continue;
                const [block] = await this.getBlocks(
                  blockNumber,
                  1,
                  headTopology.id
                );
                if (
                  !block ||
                  !block.block ||
                  !block.block_id ||
                  !block.block.transactions
                )
                  continue;
                const tx = block.block.transactions.find(
                  (t) => t.id === transaction.id
                );
                if (tx) return blockNumber.toString();
              }
              throw new Error(
                `Transaction not mined from block ${iniBlock} to ${blockNumber}`
              );
            },
          };
        }
async sendTransaction ( transaction ) { await this . call ( "chain.submit_transaction" , { transaction } ) ; const startTime = Date . now ( ) + 10000 ; return { wait : async ( type = "byTransactionId" ) => { await sleep ( startTime - Date . now ( ) - 1000 ) ; if ( type === "byTransactionId" ) { for ( let i = 0 ; i < 30 ; i += 1 ) { await sleep ( 1000 ) ; const { transactions } = await this . getTransactionsById ( [ transaction . id , ] ) ; if ( transactions && transactions [ 0 ] && transactions [ 0 ] . containing_blocks ) return transactions [ 0 ] . containing_blocks [ 0 ] ; } throw new Error ( ` ` ) ; } let blockNumber = 0 ; let iniBlock = 0 ; for ( let i = 0 ; i < 90 ; i += 1 ) { await sleep ( 1000 ) ; const { head_topology : headTopology } = await this . getHeadInfo ( ) ; if ( i === 0 ) { blockNumber = Number ( headTopology . height ) ; iniBlock = blockNumber ; } else { blockNumber += 1 ; } if ( blockNumber > Number ( headTopology . height ) ) continue ; const [ block ] = await this . getBlocks ( blockNumber , 1 , headTopology . id ) ; if ( ! block || ! block . block || ! block . block_id || ! block . block . transactions ) continue ; const tx = block . block . transactions . find ( ( t ) => t . id === transaction . id ) ; if ( tx ) return blockNumber . toString ( ) ; } throw new Error ( ` ${ iniBlock } ${ blockNumber } ` ) ; } , } ; }
Function to call "chain.submit_transaction" to send a signed
 transaction to the blockchain.
Function to call " chain . submit_transaction " to send a signed transaction to the blockchain .
// sleep some seconds before it gets mined // byBlock