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

Function getSendPayload

packages/cardpay-sdk/sdk/utils/safe-utils.ts:95–122  ·  view source on GitHub ↗
(
  web3: Web3,
  prepaidCardAddress: string,
  spendAmount: number,
  rate: string,
  action: string,
  data: string
)

Source from the content-addressed store, hash-verified

93}
94
95export async function getSendPayload(
96 web3: Web3,
97 prepaidCardAddress: string,
98 spendAmount: number,
99 rate: string,
100 action: string,
101 data: string
102): Promise<SendPayload> {
103 let relayServiceURL = await getConstant('relayServiceURL', web3);
104 let url = `${relayServiceURL}/v1/prepaid-card/${prepaidCardAddress}/send/get-params/`;
105 let options = {
106 method: 'POST',
107 headers: {
108 'Content-Type': 'application/json', //eslint-disable-line @typescript-eslint/naming-convention
109 },
110 body: JSON.stringify({
111 payment: spendAmount,
112 rate,
113 action,
114 data,
115 }),
116 };
117 let response = await fetch(url, options);
118 if (!response?.ok) {
119 throw new Error(await response.text());
120 }
121 return await response.json();
122}
123
124export async function executeTransaction(
125 web3: Web3,

Callers 4

getPayMerchantPayloadMethod · 0.90
getSplitPayloadMethod · 0.90
getTransferPayloadMethod · 0.90

Calls 1

getConstantFunction · 0.90

Tested by

no test coverage detected