Developer Questions

Ask a Question
Back to All

How to request `EscrowCreate` Sequence number for `EscrowFinish` payload?

ChatGPT would like to apologize for the confusion, so how to request Sequence number for EscrowFinish, wherein the following code successfully connects and signs anEscrowCreate, after which the suggested sdk.getTransaction(txid) line throws undefined:

        import 'https://xumm.app/assets/cdn/xumm-oauth2-pkce.min.js?v=2.7.1'
        const xumm = new XummPkce(‘……………..xumm public key……………….’, {
            implicit: true, // Implicit: allows to e.g. move from social browser to stock browser
            redirectUrl: document.location.href + '?custom_state=test'
        })
            const { sdk } = await xumm.state()
            const payload = await sdk.payload.create({
                TransactionType: 'EscrowCreate',
                Destination: borrowerXRPaddressField,
                Amount: String(1_000_000),
                CancelAfter: cancelAfter,
                Condition: condition,
            })

            if (payload.pushed) {
                alert('Payload `' + payload.uuid + '` pushed to your phone.')
            } else {
                // You can also render `payload.refs.qr_png` in your UI
                alert('Payload not pushed, opening payload...')
                window.open(payload.next.always)
            }
// START ADD REQUEST SEQUENCE CODE FOR EscrowFinish
		async function getEscrowSequence(txid) {
                	const { sdk } = await xumm.state();
                	const transaction = await sdk.getTransaction(txid); // (foobar.html:446:30)
                	return transaction.sequence;
            	}
           	 const sequence = await getEscrowSequence(payload.txid);
            	console.log('Sequence:', sequence);
 // END ADD REQUEST SEQUENCE CODE
        }
</script>```
throws:
```TypeError: Cannot read properties of undefined (reading 'trim')
    at r.Meta.<anonymous> (xumm-oauth2-pkce.min.js?v=2.7.1:1:43121)
    at Generator.next (<anonymous>)
    at xumm-oauth2-pkce.min.js?v=2.7.1:1:38446
    at new Promise (<anonymous>)
    at n (xumm-oauth2-pkce.min.js?v=2.7.1:1:38191)
    at r.Meta.getTransaction (xumm-oauth2-pkce.min.js?v=2.7.1:1:43051)
    at r.XummSdkJwt.getTransaction (xumm-oauth2-pkce.min.js?v=2.7.1:1:48931)
    at getEscrowSequence (foobar.html:443:47)
    at async document.getElementById.onclick (foobar.html:446:30)```