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","Sample Web")
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 = sentDeros / pricePerBlock
60 IF minimumBlocks <= newlyPaidBlocks && newlyPaidBlocks >= expectedBlocks THEN GOTO 80
70 RETURN 1
80 LET blockHeight = BLOCK_HEIGHT()
90 LET paidUntilBlock = 0
100 IF EXISTS("AD-" + smartContract) == 0 THEN GOTO 120
110 LET paidUntilBlock = LOAD("AD-" + smartContract)
120 IF paidUntilBlock > blockHeight THEN GOTO 140
130 LET paidUntilBlock = blockHeight
140 LET paidUntilBlock = paidUntilBlock + newlyPaidBlocks
150 STORE("AD-" + smartContract, paidUntilBlock)
160 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","Sample Web")
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 = sentDeros / pricePerBlock
60 IF minimumBlocks <= newlyPaidBlocks && newlyPaidBlocks >= expectedBlocks THEN GOTO 80
70 RETURN 1
80 LET blockHeight = BLOCK_HEIGHT()
90 LET paidUntilBlock = 0
100 IF EXISTS("AD-" + smartContract) == 0 THEN GOTO 120
110 LET paidUntilBlock = LOAD("AD-" + smartContract)
120 IF paidUntilBlock > blockHeight THEN GOTO 140
130 LET paidUntilBlock = blockHeight
140 LET paidUntilBlock = paidUntilBlock + newlyPaidBlocks
150 STORE("AD-" + smartContract, paidUntilBlock)
160 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'] |