SC CODE: Function CreateProfile(dero_name String, bio String) Uint64
10 DIM profile_count as Uint64
20 DIM signer as String
30 LET signer = SIGNER()
40 IF EXISTS("signer_" + signer) != 0 THEN GOTO 110 // if signer already has a profile
50 LET profile_count = LOAD("profile_count") + 1
60 STORE("profile_address_" + profile_count, signer)
70 STORE("signer_" + signer, profile_count)
80 STORE("dero_name_" + profile_count, dero_name)
90 STORE("bio_" + profile_count, bio)
100 STORE("profile_count", profile_count)
110 RETURN 0
120 RETURN 1 // Error: profile already exists
End Function
Function Deposit() Uint64
10 RETURN 0
End Function
Function UpdateProfile(dero_name String, bio String) Uint64
10 DIM signer as String
20 DIM userId as Uint64
30 LET signer = SIGNER()
40 IF EXISTS("signer_" + signer) == 0 THEN GOTO 70 // if signer doesn't exist
50 LET userId = LOAD("signer_" + signer)
60 STORE("dero_name_" + userId, dero_name)
70 STORE("bio_" + userId, bio)
80 RETURN 0
90 RETURN 1 // Error: signer doesn't exist
End Function
Function GetProfile(profile_index Uint64) String
10 DIM dero_name as String
20 DIM bio as String
30 dero_name = LOAD("dero_name_" + profile_index)
40 bio = LOAD("bio_" + profile_index)
50 RETURN "dero_name: " + dero_name + ", bio: " + bio
End Function
// if signer is owner, withdraw any requested funds
// if everthing is okay, thety will be showing in signers wallet
Function Withdraw( amount Uint64) Uint64
10 IF (LOAD("owner")) == (SIGNER()) THEN GOTO 30
20 RETURN 1
30 SEND_DERO_TO_ADDRESS(SIGNER(),amount)
40 RETURN 0
End Function
Function Initialize() Uint64
10 STORE("owner", SIGNER())
20 STORE("profile_count", 0) // initial number of profiles
30 STORE("contract_balance", 0) // initial contract balance
40 RETURN 0
End Function
|
SC Arguments: [Name:SC_ACTION Type:uint64 Value:'1' Name:SC_CODE Type:string Value:'Function CreateProfile(dero_name String, bio String) Uint64
10 DIM profile_count as Uint64
20 DIM signer as String
30 LET signer = SIGNER()
40 IF EXISTS("signer_" + signer) != 0 THEN GOTO 110 // if signer already has a profile
50 LET profile_count = LOAD("profile_count") + 1
60 STORE("profile_address_" + profile_count, signer)
70 STORE("signer_" + signer, profile_count)
80 STORE("dero_name_" + profile_count, dero_name)
90 STORE("bio_" + profile_count, bio)
100 STORE("profile_count", profile_count)
110 RETURN 0
120 RETURN 1 // Error: profile already exists
End Function
Function Deposit() Uint64
10 RETURN 0
End Function
Function UpdateProfile(dero_name String, bio String) Uint64
10 DIM signer as String
20 DIM userId as Uint64
30 LET signer = SIGNER()
40 IF EXISTS("signer_" + signer) == 0 THEN GOTO 70 // if signer doesn't exist
50 LET userId = LOAD("signer_" + signer)
60 STORE("dero_name_" + userId, dero_name)
70 STORE("bio_" + userId, bio)
80 RETURN 0
90 RETURN 1 // Error: signer doesn't exist
End Function
Function GetProfile(profile_index Uint64) String
10 DIM dero_name as String
20 DIM bio as String
30 dero_name = LOAD("dero_name_" + profile_index)
40 bio = LOAD("bio_" + profile_index)
50 RETURN "dero_name: " + dero_name + ", bio: " + bio
End Function
// if signer is owner, withdraw any requested funds
// if everthing is okay, thety will be showing in signers wallet
Function Withdraw( amount Uint64) Uint64
10 IF (LOAD("owner")) == (SIGNER()) THEN GOTO 30
20 RETURN 1
30 SEND_DERO_TO_ADDRESS(SIGNER(),amount)
40 RETURN 0
End Function
Function Initialize() Uint64
10 STORE("owner", SIGNER())
20 STORE("profile_count", 0) // initial number of profiles
30 STORE("contract_balance", 0) // initial contract balance
40 RETURN 0
End Function
'] |