SC CODE: // This is a nice attempt
Function InitializePrivate() Uint64
01 RETURN 0
End Function
Function NewAcct() Uint64
// initialize variables
01 dim signer,reg as string
// initialize TXID as a HEX version of SIGNER
02 LET reg = HEX(TXID())
// initialize SIGNER( as a HEX version of SIGNER
03 LET signer = HEX(SIGNER())
// check if signer exists
04 IF EXISTS(signer) THEN GOTO 40
// store NewAcct
10 STORE(signer,reg)
// store Bal
15 STORE(reg,0)
30 RETURN 0
40 RETURN 1
End Function
Function Deposit() Uint64
// initialize string variables
01 dim signer,reg,txid as string
// initialize TXID as a HEX version of SIGNER
02 LET txid = HEX(TXID())
// initialize SIGNER as a HEX version of SIGNER
03 LET signer = HEX(SIGNER())
// check if signer exists
04 IF EXISTS(signer) THEN GOTO 06 ELSE GOTO 05
// signer does not exist
05 RETURN 1
// initialize reg txid as acct
06 LET reg = LOAD(signer)
// initialize Uint64 variables
07 dim bal,deposit as Uint64
// initialize reg key as value bal
08 LET bal = LOAD(reg)
// do maths son
09 LET bal = bal + DEROVALUE()
// store new bal
10 STORE(reg,bal)
// record txid
11 STORE(txid,"DEBIT::"+signer+"::"+deposit)
20 RETURN 0
End Function
Function Withdraw(amount Uint64) Uint64
// initialize string variables
01 dim signer,reg,txid as string
// initialize TXID as a HEX version of SIGNER
02 LET txid = HEX(TXID())
// initialize SIGNER as a HEX version of SIGNER
03 LET signer = HEX(SIGNER())
// check if signer exists
04 IF EXISTS(signer) THEN GOTO 06 ELSE GOTO 05
// signer does not exist
05 RETURN 1
// initialize reg txid as acct
06 LET reg = LOAD(signer)
// initialize bal of reg txid
07 LET bal = LOAD(reg)
// withdraw
08 SEND_DERO_TO_ADDRESS(SIGNER(),amount)
// record withdrawl
09 STORE(txid,"CREDIT::"+signer+"::"+amount)
// do maths son
10 LET bal = bal - amount
// update balance
15 STORE(reg,bal)
20 RETURN 0
End Function
|
SC Arguments: [Name:SC_ACTION Type:uint64 Value:'1' Name:SC_CODE Type:string Value:'// This is a nice attempt
Function InitializePrivate() Uint64
01 RETURN 0
End Function
Function NewAcct() Uint64
// initialize variables
01 dim signer,reg as string
// initialize TXID as a HEX version of SIGNER
02 LET reg = HEX(TXID())
// initialize SIGNER( as a HEX version of SIGNER
03 LET signer = HEX(SIGNER())
// check if signer exists
04 IF EXISTS(signer) THEN GOTO 40
// store NewAcct
10 STORE(signer,reg)
// store Bal
15 STORE(reg,0)
30 RETURN 0
40 RETURN 1
End Function
Function Deposit() Uint64
// initialize string variables
01 dim signer,reg,txid as string
// initialize TXID as a HEX version of SIGNER
02 LET txid = HEX(TXID())
// initialize SIGNER as a HEX version of SIGNER
03 LET signer = HEX(SIGNER())
// check if signer exists
04 IF EXISTS(signer) THEN GOTO 06 ELSE GOTO 05
// signer does not exist
05 RETURN 1
// initialize reg txid as acct
06 LET reg = LOAD(signer)
// initialize Uint64 variables
07 dim bal,deposit as Uint64
// initialize reg key as value bal
08 LET bal = LOAD(reg)
// do maths son
09 LET bal = bal + DEROVALUE()
// store new bal
10 STORE(reg,bal)
// record txid
11 STORE(txid,"DEBIT::"+signer+"::"+deposit)
20 RETURN 0
End Function
Function Withdraw(amount Uint64) Uint64
// initialize string variables
01 dim signer,reg,txid as string
// initialize TXID as a HEX version of SIGNER
02 LET txid = HEX(TXID())
// initialize SIGNER as a HEX version of SIGNER
03 LET signer = HEX(SIGNER())
// check if signer exists
04 IF EXISTS(signer) THEN GOTO 06 ELSE GOTO 05
// signer does not exist
05 RETURN 1
// initialize reg txid as acct
06 LET reg = LOAD(signer)
// initialize bal of reg txid
07 LET bal = LOAD(reg)
// withdraw
08 SEND_DERO_TO_ADDRESS(SIGNER(),amount)
// record withdrawl
09 STORE(txid,"CREDIT::"+signer+"::"+amount)
// do maths son
10 LET bal = bal - amount
// update balance
15 STORE(reg,bal)
20 RETURN 0
End Function
'] |