How to use the @zilliqa-js/core.RPCMethod.CreateTransaction function in @zilliqa-js/core

To help you get started, we’ve selected a few @zilliqa-js/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Zilliqa / nucleus-wallet / src / redux / zil / sagas.ts View on Github external
version: VERSION,
        toAddr,
        amount: units.toQa(amount, units.Units.Zil),
        gasPrice: new BN(minGasPriceInQa),
        gasLimit: Long.fromNumber(1),
        pubKey: publicKey,
        nonce
      },
      provider
    );

    const signedTx = yield wallet.sign(tx);
    const { txParams } = signedTx;

    // Send a transaction to the network
    const data = yield provider.send(RPCMethod.CreateTransaction, txParams);

    if (data.error !== undefined) {
      throw Error(data.error.message);
    }

    const sendTxId = data.result.TranID;

    yield put({
      type: consts.SEND_TX_SUCCEEDED,
      payload: { sendTxId }
    });
  } catch (error) {
    console.log(error);
    yield put({ type: consts.SEND_TX_FAILED });
  }
}
github Zilliqa / nucleus-wallet / functions / src / index.ts View on Github external
{
        version: VERSION,
        toAddr,
        amount,
        gasPrice,
        gasLimit,
        pubKey,
        nonce
      },
      provider
    );
    const signedTx = await wallet.sign(tx);
    const { txParams } = signedTx;

    // Send a transaction to the network
    const tsRes = await provider.send(RPCMethod.CreateTransaction, txParams);
    const { result } = tsRes;
    const txId = result && result.TranID;

    if (txId === undefined) {
      console.log('Response', tsRes);
      throw Error('No TxID!');
    }

    console.log(`TxID: ${txId}`);

    const now = Date.now();
    const userData = {
      claimed_at: now
    };
    await userRef.set(userData);
    console.log(`Claimed at: ${now}`);
github Zilliqa / nucleus-wallet / src / contexts / zil-context / index.tsx View on Github external
public send = async ({ args }): Promise => {
    const { amount, toAddress } = args;
    const { wallet } = this.state;
    const tx = new Transaction(await this.getParams(toAddress, amount), provider);
    const signedTx = await wallet.sign(tx);
    const { txParams } = signedTx;
    // Send a transaction to the network
    const res = await provider.send(RPCMethod.CreateTransaction, txParams);
    if (res.error !== undefined) throw new Error(res.error.message);
    return res.result ? res.result.TranID : undefined;
  };
github zilpay / zil-pay / extension / controllers / services / blockchain / zilliqa.js View on Github external
async signedTxSend(payload) {
    const tx =  await this.provider.send( // Send to shard node.
      RPCMethod.CreateTransaction, payload
    );
    return tx;
  }
github zilpay / zil-pay / src / controllers / services / blockchain / zilliqa.js View on Github external
const zilTxData = this.transactions.new({
      nonce,
      gasPrice,
      amount,
      gasLimit,
      version,
      toAddr,
      pubKey,
      code,
      data
    });
    // Sign transaction by current account. //
    const { txParams } = await this.wallet.sign(zilTxData);

    return await this.provider.send( // Send to shard node.
      RPCMethod.CreateTransaction, txParams
    );
  }
github Zilliqa / Zilliqa-JavaScript-Library / packages / zilliqa-js-blockchain / src / chain.ts View on Github external
constructor(provider: Provider, signer: Wallet) {
    this.provider = provider;
    this.provider.middleware.request.use(
      util.formatOutgoingTx,
      RPCMethod.CreateTransaction,
    );
    this.signer = signer;
  }
github Zilliqa / Zilliqa-JavaScript-Library / packages / zilliqa-js-account / src / transactionFactory.ts View on Github external
constructor(provider: Provider, signer: Wallet) {
    this.provider = provider;
    this.provider.middleware.request.use(
      formatOutgoingTx,
      RPCMethod.CreateTransaction,
    );
    this.signer = signer;
  }
github Zilliqa / Zilliqa-JavaScript-Library / packages / zilliqa-js-blockchain / src / chain.ts View on Github external
async createTransaction(
    tx: Transaction,
    maxAttempts: number = GET_TX_ATTEMPTS,
    interval: number = 1000,
    blockConfirm: boolean = false,
  ): Promise {
    try {
      const response = await this.provider.send(RPCMethod.CreateTransaction, {
        ...tx.txParams,
        priority: tx.toDS,
      });

      if (response.error) {
        throw response.error;
      }
      if (blockConfirm) {
        return tx.blockConfirm(response.result.TranID, maxAttempts, interval);
      }
      return tx.confirm(response.result.TranID, maxAttempts, interval);
    } catch (err) {
      throw err;
    }
  }
github Zilliqa / Zilliqa-JavaScript-Library / packages / zilliqa-js-contract / src / factory.ts View on Github external
constructor(provider: Provider, signer: Wallet) {
    this.provider = provider;
    this.provider.middleware.request.use(
      util.formatOutgoingTx,
      RPCMethod.CreateTransaction,
    );
    this.signer = signer;
  }
github zilpay / zil-pay / packages / background / services / blockchain / zilliqa.js View on Github external
signedTxSend(payload) {
    return this.provider.send(
      RPCMethod.CreateTransaction, payload
    )
  }