Created
July 31, 2019 15:52
-
-
Save majecty/50a040a60bcd4c277a99dbeaead73a01 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
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