Overview
App is an interface to the user account balance and it is used to transfer MOBI within accounts.
App Object
Attribute | Type | Description |
---|---|---|
seed | String | DApp private seed |
address | String | User public key |
Secret Seeds
Make sure you keep all the secret seeds stored safely, extracting into ENV variables or equivalent. Keys present throughout the documentation only serve for example purposes and belong to an account in the Test network.
Initializing
# App private seed
sdapp = "SBBT7NRAKW43LN6ZGSZI37HEJDYWOC62LIZUL35KHO6NI2SKJLEPVAY4"
# User public key
guser = "GDPNZJR42G4PVA3235JHCGGTU2J54X4XGJIMQGDJXYGHQDY6MQW5SZ5Y"
dapp = Mobius::Client::App.new(sdapp, guser)
# =>
#<Mobius::Client::App:0x00007fe654093bd8
@seed="SBBT7NRAKW43LN6ZGSZI37HEJDYWOC62LIZUL35KHO6NI2SKJLEPVAY4",
@address="GDPNZJR42G4PVA3235JHCGGTU2J54X4XGJIMQGDJXYGHQDY6MQW5SZ5Y">
// App private seed
const sdapp = 'SBBT7NRAKW43LN6ZGSZI37HEJDYWOC62LIZUL35KHO6NI2SKJLEPVAY4';
// User public key
const guser = 'GDPNZJR42G4PVA3235JHCGGTU2J54X4XGJIMQGDJXYGHQDY6MQW5SZ5Y';
const dapp = await Mobius.AppBuilder.build(sdapp, guser);
Methods
App Account###
Returns the dapp account details.
dapp.app_account # object => dapp_account
dapp.appAccount // object => {...}
App Balance###
Returns the dapp balance.
dapp.app_balance # float => 990.0
dapp.appBalance // int => 990
App Keypair###
Returns the dapp keypair
dapp.app_kepair # object => dapp_keypair
dapp.appKeypair // object => {...}
Authorized###
Returns boolean based on user authorization
app.authorized? # bool => true
app.authorized // bool => true
User Account###
Returns the user account details
dapp.user_account # object => user_account
dapp.userAccount // object => {...}
User Balance###
Returns the user balance
dapp.user_balance # float => 990.0
dapp.userBalance // int => 990
User Keypair###
Returns the user public key
dapp.user_keypair # object => user_keypair
dapp.userKeypair // object => {...}
Charge###
Charges a users wallet and optionally transfers to a target address.
#charge(amount, target_address: nil) ⇒ Object
dapp.charge(5)
#<Hyperclient::Resource self_link:nil attributes:
#<Hyperclient::Attributes:0x00007fe65480ba50
@collection={
"hash"=>"821c60...5fc09f",
"ledger"=>9634000,
"envelope_xdr"=>"AAAAAN...eqaQU=",
"result_xdr"=>"AAAAAA...AAAAA=",
"result_meta_xdr"=>"AAAAAA...AAAAAA"
}>>
const result = await dapp.charge(5);
/** result =>
* {
* hash: '821c60...5fc09f',
* legder: 9634000,
* envelope_xdr: "AAAAAN...eqaQU=",
* result_xdr: "AAAAAA...AAAAA=",
* result_meta_xdr: 'AAAAAA...AAAAAA'
* }
*/
XDR Viewer
Click the links below to open the Stellar XDR Viewer for each one.
Payout###
Sends money from DApp account to the user's account or target_address, if given.
Ruby: #payout(amount, target_address: user_keypair.address) ⇒ Object
dapp.payout(2)
#<Hyperclient::Resource self_link:nil attributes:
#<Hyperclient::Attributes:0x00007ff65445fc48
@collection={
"hash"=>"4c4ce8...dc8cc4",
"ledger"=>9824154,
"envelope_xdr"=>"AAAAAN...tXwAY=",
"result_xdr"=>"AAAAAA...AAAAA=",
"result_meta_xdr"=>"AAAAAA...AAAAAA"
}>>
const result = await dapp.payout(2);
/** result =>
* {
* hash: '4c4ce8...dc8cc4',
* legder: 9824154,
* envelope_xdr: "AAAAAN...tXwAY",
* result_xdr: "AAAAAA...AAAAA=",
* result_meta_xdr: 'AAAAAA...AAAAAA'
* }
*/
XDR Viewer
Click the links below to open the Stellar XDR Viewer for each one.
Transfer###
Sends money from the users account to third party.
#transfer(amount, address) ⇒ Object
# Target address public key
target = "GASD34FQS3V54JK62YV4APLMTW56YW5YUFZWBVCCQ7Y5RSEQ6PLL5COZ"
dapp.transfer(2, target)
<Hyperclient::Resource self_link:nil attributes:
<Hyperclient::Attributes:0x00007f01a8009ed8
@collection={
"hash"=>"e61351...dd7a37",
"ledger"=>9842412,
"envelope_xdr"=>"AAAAAN...KaMQQ=",
"result_xdr"=>"AAAAAA...AAAAA=",
"result_meta_xdr"=>"AAAAAA...AAAAAA"
}>>
// Target address public key
const target = 'GASD34FQS3V54JK62YV4APLMTW56YW5YUFZWBVCCQ7Y5RSEQ6PLL5COZ';
const result = await dapp.transfer(2, target);
/** result =>
* {
* hash: 'e61351...dd7a37',
* legder: 9842412,
* envelope_xdr: "AAAAAN...KaMQQ=",
* result_xdr: "AAAAAA...AAAAA=",
* result_meta_xdr: 'AAAAAA...AAAAAA'
* }
*/
XDR Viewer
Click the links below to open the Stellar XDR Viewer for each one.