Created
March 27, 2024 20:56
-
-
Save mgild/ddc209ad5ab13daf33d80c4c9dfc9831 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async sendRestTransaction( | |
serializedTx: Uint8Array | Buffer | Array<number>, | |
retries, | |
rpcEndpoint = this.defaultConnection.rpcEndpoint, | |
skipPreFlight = true | |
): Promise<TransactionSignature> { | |
const res = await fetch(rpcEndpoint, { | |
method: "POST", | |
headers: { | |
"Content-Type": "application/json", | |
}, | |
body: JSON.stringify({ | |
jsonrpc: "2.0", | |
id: Math.round(Math.random() * 1_000_000), | |
method: "sendTransaction", | |
params: [ | |
serializedTx!.toString("base64"), | |
{ | |
skipPreflight: skipPreFlight, | |
encoding: "base64", | |
maxRetries: retries, | |
}, | |
], | |
}), | |
}); | |
return ((await res.json()) as any)!.result!; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment