MCPcopy Create free account
hub / github.com/cardstack/cardstack / gasEstimate

Function gasEstimate

packages/cardpay-sdk/sdk/utils/safe-utils.ts:64–93  ·  view source on GitHub ↗
(
  web3: Web3,
  from: string,
  to: string,
  value: string,
  data: string,
  operation: number,
  gasToken: string
)

Source from the content-addressed store, hash-verified

62}
63
64export async function gasEstimate(
65 web3: Web3,
66 from: string,
67 to: string,
68 value: string,
69 data: string,
70 operation: number,
71 gasToken: string
72): Promise<Estimate> {
73 let relayServiceURL = await getConstant('relayServiceURL', web3);
74 let url = `${relayServiceURL}/v2/safes/${from}/transactions/estimate/`;
75 let options = {
76 method: 'POST',
77 headers: {
78 'Content-Type': 'application/json', //eslint-disable-line @typescript-eslint/naming-convention
79 },
80 body: JSON.stringify({
81 to,
82 value,
83 data,
84 operation,
85 gasToken,
86 }),
87 };
88 let response = await fetch(url, options);
89 if (!response?.ok) {
90 throw new Error(await response.text());
91 }
92 return await response.json();
93}
94
95export async function getSendPayload(
96 web3: Web3,

Callers 5

relayTokensMethod · 0.90
createMethod · 0.90
claimMethod · 0.90
sendTokensMethod · 0.90
setSupplierInfoDIDMethod · 0.90

Calls 1

getConstantFunction · 0.90

Tested by

no test coverage detected