Skip to content

Instantly share code, notes, and snippets.

@majecty
Created July 31, 2019 15:52
Show Gist options
  • Save majecty/50a040a60bcd4c277a99dbeaead73a01 to your computer and use it in GitHub Desktop.
Save majecty/50a040a60bcd4c277a99dbeaead73a01 to your computer and use it in GitHub Desktop.
import { SDK } from "codechain-sdk";
const fromPlatformAddress = "wccq9ma52hnvy3fsalpavqazu3qxptfemj8zgtj4gk5";
const toPlatformAddress = "wccq9ma52hnvy3fsalpavqazu3qxptfemj8zgtj4gk5";
const passphrase = "";
async function main() {
const sdk = new SDK({
server: "https://corgi-rpc.codechain.io",
networkId: "wc",
keyStoreType: {
type: "local",
path: "./keystore.db"
}
});
const pay = /* Fill this line */ null;
const seq = /* Fill this line */ 999;
const signedTx = /* Sign the Tx */ null;
const txHash = /* Send signed transaction */ null;
console.log(`TxHash ${txHash}`);
for (let index = 0; index < 30; index++) {
const contained = await sdk.rpc.chain.containsTransaction(txHash);
if (contained) {
console.log(`Transaction ${txHash.toString()} is mined`);
return;
}
delay(1000);
}
console.log(
`The transaction(${txHash.toString()}) is not mined after 30 seconds. Please check net network status or your mistake`
);
}
main().catch(console.error);
function delay(ms: number) {
return new Promise(resolve => {
setTimeout(() => {
resolve();
}, ms);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment