aeternity.ros
1 request_funds(1){ 2 find_account{ 3 currency = {"symbol":"AE", "decimals":18}; 4 random_account = find_balance({ 5 "minimum_balance":{ 6 "value": "0", 7 "currency": {{currency}} 8 }, 9 "create_limit":1 10 }); 11 }, 12 13 // Create a separate scenario to request funds so that 14 // the address we are using to request funds does not 15 // get rolled back if funds do not yet exist. 16 request{ 17 loaded_account = find_balance({ 18 "account_identifier": {{random_account.account_identifier}}, 19 "minimum_balance":{ 20 "value": "10000000000000000", 21 "currency": {{currency}} 22 } 23 }); 24 } 25 } 26 27 create_account(1){ 28 create{ 29 network = {"network":"ae_uat", "blockchain":"aeternity"}; 30 key = generate_key({"curve_type": "edwards25519"}); 31 account = derive({ 32 "network_identifier": {{network}}, 33 "public_key": {{key.public_key}} 34 }); 35 36 // If the account is not saved, the key will be lost! 37 save_account({ 38 "account_identifier": {{account.account_identifier}}, 39 "keypair": {{key}} 40 }); 41 } 42 } 43 44 transfer(10){ 45 transfer{ 46 transfer.network = {"network":"local_ceres_testnet", "blockchain":"aeternity"}; 47 currency = {"symbol":"AE", "decimals":18}; 48 sender = find_balance({ 49 "minimum_balance":{ 50 "value": "10000000000000000", 51 "currency": {{currency}} 52 } 53 }); 54 55 // Set the recipient_amount as some value <= sender.balance-max_fee 56 max_fee = "84000000000000"; 57 available_amount = {{sender.balance.value}} - {{max_fee}}; 58 recipient_amount = random_number({"minimum": "1", "maximum": {{available_amount}}}); 59 print_message({"recipient_amount":{{recipient_amount}}}); 60 61 // Find recipient and construct operations 62 sender_amount = 0 - {{recipient_amount}}; 63 recipient = find_balance({ 64 "not_account_identifier":[{{sender.account_identifier}}], 65 "minimum_balance":{ 66 "value": "0", 67 "currency": {{currency}} 68 }, 69 "create_limit": 100, 70 "create_probability": 50 71 }); 72 transfer.confirmation_depth = "1"; 73 transfer.operations = [ 74 { 75 "operation_identifier":{"index":0}, 76 "type":"Spend.amount", 77 "account":{{sender.account_identifier}}, 78 "amount":{ 79 "value":{{sender_amount}}, 80 "currency":{{currency}} 81 } 82 }, 83 { 84 "operation_identifier":{"index":1}, 85 "type":"Spend.amount", 86 "account":{{recipient.account_identifier}}, 87 "amount":{ 88 "value":{{recipient_amount}}, 89 "currency":{{currency}} 90 } 91 } 92 ]; 93 } 94 }