Creating Transactions

In this demo we are just performing typed message signing for Goerli ETH. The transaction values are hard coded in the backend demo application hence these values can be customized by updating the transaction controller in the backend server.

The front-end application just calls the relevant endpoint to initiate the transaction process:

...

createTransaction: async () => {
  if (!apiService) {
    throw new Error("apiService is not initialized");
  }
  const { deviceId } = get();
  const newTxData = await apiService.createTransaction(deviceId);
  const txs = updateOrAddTx(get().txs, newTxData);
  set((state) => ({ ...state, txs }));
}

...
...

public async createTransaction(deviceId: string): Promise<ITransactionData> {
  const createTxResponse = await this._postCall(`api/devices/${deviceId}/transactions`);
  return createTxResponse;
}

...