-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquest3.kt
43 lines (35 loc) · 1.45 KB
/
quest3.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package set2
import Keys
import org.stellar.sdk.*
fun main() {
val server = Server("https://horizon-testnet.stellar.org")
val questAccountKeys = KeyPair.fromSecretSeed(Keys.quest2PrivateKey)
val questAccount = server.accounts().account(questAccountKeys.accountId)
val helperAccountKeys = KeyPair.fromSecretSeed(Keys.set2helperKey)
val helperAccount = server.accounts().account(helperAccountKeys.accountId)
val txBuilder = Transaction.Builder(questAccount, Network.TESTNET)
.setBaseFee(FeeBumpTransaction.MIN_BASE_FEE)
.setTimeout(180)
// payback to friendbot as usual but from quest acc
txBuilder.addOperation(
PaymentOperation.Builder("GAIH3ULLFQ4DGSECF2AR555KZ4KNDGEKN4AFI4SU2M7B43MGK3QJZNSR", AssetTypeNative(), "10")
.build()
)
val innerTx = txBuilder.build()
innerTx.sign(questAccountKeys)
val feeTxBuilder = FeeBumpTransaction.Builder(innerTx)
.setBaseFee(FeeBumpTransaction.MIN_BASE_FEE.toLong())
.setFeeAccount(helperAccount.accountId)
val feeBumpTransaction = feeTxBuilder.build()
feeBumpTransaction.sign(helperAccountKeys)
println("Executing tx..")
try {
val response = server.submitTransaction(feeBumpTransaction)
println("Success!")
println("txHash: ${response.hash}")
println("result: ${response.resultXdr.get()}")
} catch (e: Exception) {
println("Something went wrong!")
println(e.message)
}
}