SC CODE: Function InitializePrivate() Uint64
10 IF EXISTS("Owner")==0 THEN GOTO 30
20 RETURN 1
30 DIM signer as String
40 LET signer=SIGNER()
50 STORE("Owner",signer)
60 STORE("OwnerAddress",ADDRESS_STRING(signer))
70 STORE("Name","TheOriginal")
80 STORE("PricePerBlock",0)
90 STORE("MinimumBlocks",0)
100 RETURN 0
End Function
Function AddSmartContract(smartContract String, expectedBlocks Uint64) Uint64
10 DIM pricePerBlock, minimumBlocks, newlyPaidBlocks, paidUntilBlock, blockHeight, sentDeros as Uint64
20 LET sentDeros = DEROVALUE()
30 LET pricePerBlock = LOAD("PricePerBlock")
40 LET minimumBlocks = LOAD("MinimumBlocks")
50 LET newlyPaidBlocks = expectedBlocks
60 IF pricePerBlock == 0 THEN GOTO 80
70 LET newlyPaidBlocks = sentDeros / pricePerBlock
80 IF minimumBlocks <= newlyPaidBlocks && newlyPaidBlocks >= expectedBlocks THEN GOTO 100
90 RETURN 1
100 LET blockHeight = BLOCK_HEIGHT()
110 LET paidUntilBlock = 0
120 IF EXISTS("AD-" + smartContract) == 0 THEN GOTO 140
130 LET paidUntilBlock = LOAD("AD-" + smartContract)
140 IF paidUntilBlock > blockHeight THEN GOTO 160
150 LET paidUntilBlock = blockHeight
160 LET paidUntilBlock = paidUntilBlock + newlyPaidBlocks
170 STORE("AD-" + smartContract, paidUntilBlock)
180 SEND_DERO_TO_ADDRESS(LOAD("Owner"),sentDeros)
200 RETURN 0
End Function
Function UpdateSmartContract(name String, pricePerBlock Uint64, minimumBlocks Uint64) Uint64
10 IF LOAD("Owner") == SIGNER() THEN GOTO 30
20 RETURN 1;
30 STORE("Name", name)
40 STORE("PricePerBlock", pricePerBlock)
50 STORE("MinimumBlocks", minimumBlocks)
60 RETURN 0
End Function
Function TransferOwnership(newowner String) Uint64
10 IF LOAD("Owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 STORE("tmpowner", ADDRESS_RAW(newowner))
40 RETURN 0
End Function
Function ClaimOwnership() Uint64
10 DIM signer as String
20 LET signer = SIGNER()
30 IF LOAD("tmpowner") == signer THEN GOTO 50
40 RETURN 1
50 STORE("Owner", signer)
60 STORE("OwnerAddress", ADDRESS_STRING(SIGNER()))
70 DELETE("tmpowner")
80 RETURN 0
End Function |
SC Arguments: [Name:SC_ACTION Type:uint64 Value:'1' Name:SC_CODE Type:string Value:'Function InitializePrivate() Uint64
10 IF EXISTS("Owner")==0 THEN GOTO 30
20 RETURN 1
30 DIM signer as String
40 LET signer=SIGNER()
50 STORE("Owner",signer)
60 STORE("OwnerAddress",ADDRESS_STRING(signer))
70 STORE("Name","TheOriginal")
80 STORE("PricePerBlock",0)
90 STORE("MinimumBlocks",0)
100 RETURN 0
End Function
Function AddSmartContract(smartContract String, expectedBlocks Uint64) Uint64
10 DIM pricePerBlock, minimumBlocks, newlyPaidBlocks, paidUntilBlock, blockHeight, sentDeros as Uint64
20 LET sentDeros = DEROVALUE()
30 LET pricePerBlock = LOAD("PricePerBlock")
40 LET minimumBlocks = LOAD("MinimumBlocks")
50 LET newlyPaidBlocks = expectedBlocks
60 IF pricePerBlock == 0 THEN GOTO 80
70 LET newlyPaidBlocks = sentDeros / pricePerBlock
80 IF minimumBlocks <= newlyPaidBlocks && newlyPaidBlocks >= expectedBlocks THEN GOTO 100
90 RETURN 1
100 LET blockHeight = BLOCK_HEIGHT()
110 LET paidUntilBlock = 0
120 IF EXISTS("AD-" + smartContract) == 0 THEN GOTO 140
130 LET paidUntilBlock = LOAD("AD-" + smartContract)
140 IF paidUntilBlock > blockHeight THEN GOTO 160
150 LET paidUntilBlock = blockHeight
160 LET paidUntilBlock = paidUntilBlock + newlyPaidBlocks
170 STORE("AD-" + smartContract, paidUntilBlock)
180 SEND_DERO_TO_ADDRESS(LOAD("Owner"),sentDeros)
200 RETURN 0
End Function
Function UpdateSmartContract(name String, pricePerBlock Uint64, minimumBlocks Uint64) Uint64
10 IF LOAD("Owner") == SIGNER() THEN GOTO 30
20 RETURN 1;
30 STORE("Name", name)
40 STORE("PricePerBlock", pricePerBlock)
50 STORE("MinimumBlocks", minimumBlocks)
60 RETURN 0
End Function
Function TransferOwnership(newowner String) Uint64
10 IF LOAD("Owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 STORE("tmpowner", ADDRESS_RAW(newowner))
40 RETURN 0
End Function
Function ClaimOwnership() Uint64
10 DIM signer as String
20 LET signer = SIGNER()
30 IF LOAD("tmpowner") == signer THEN GOTO 50
40 RETURN 1
50 STORE("Owner", signer)
60 STORE("OwnerAddress", ADDRESS_STRING(SIGNER()))
70 DELETE("tmpowner")
80 RETURN 0
End Function'] |