ethers/lib/utils#fetchJson TypeScript Examples
The following examples show how to use
ethers/lib/utils#fetchJson.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: hubble.ts From hubble-contracts with MIT License | 6 votes |
async transfer(
fromIndex: BigNumberish,
toIndex: BigNumberish,
amount: BigNumberish,
fee: BigNumberish
) {
const fromIndexBN = BigNumber.from(fromIndex);
const { nonce } = await this.getState(fromIndexBN.toNumber());
const tx = new TransferOffchainTx(
fromIndexBN,
BigNumber.from(toIndex),
BigNumber.from(amount),
BigNumber.from(fee),
nonce
);
tx.signature = this.group
.getUser(fromIndexBN.toNumber())
.signRaw(tx.message());
const body = { bytes: tx.serialize() };
const result = await fetchJson(
`${this.address}/tx`,
JSON.stringify(body)
);
console.log(result);
}
Example #2
Source File: hubble.ts From hubble-contracts with MIT License | 5 votes |
async getState(stateID: number) {
const state = await fetchJson(`${this.address}/user/state/${stateID}`);
return state;
}