SC CODE: // DeroBeats Registry — MV4 (minimal v4)
// Return codes: 0=ok 1=error
Function Initialize() Uint64
10 IF EXISTS("owner") THEN GOTO 99
20 STORE("owner", ADDRESS_STRING(SIGNER()))
30 STORE("total_songs", 0)
40 STORE("platform_name", "DeroBeats")
50 STORE("platform_url", "derobeats.tela")
60 STORE("var_header_name", "DeroBeats Registry MV4")
61 STORE("var_header_description", "Minimal song registry for DeroBeats.")
62 STORE("var_header_icon", "")
98 RETURN 0
99 RETURN 1
End Function
Function RegisterSong(songSCID String, title String, artist String, genre String, ipfsHash String, previewArtCid String) Uint64
10 IF EXISTS(ADDRESS_STRING(SIGNER())) THEN GOTO 12
11 STORE(ADDRESS_STRING(SIGNER()), 1)
12 IF songSCID == "" THEN GOTO 99
15 IF title == "" THEN GOTO 99
20 IF artist == "" THEN GOTO 99
25 IF EXISTS(songSCID + "_registered") THEN GOTO 99
30 DIM count as Uint64
35 LET count = LOAD("total_songs")
40 STORE("song_" + count, songSCID)
45 STORE(songSCID + "_registered", 1)
50 STORE(songSCID + "_title", title)
55 STORE(songSCID + "_artist", artist)
60 STORE(songSCID + "_artist_addr", ADDRESS_STRING(SIGNER()))
65 IF genre == "" THEN GOTO 70
68 STORE(songSCID + "_genre", genre)
69 GOTO 75
70 STORE(songSCID + "_genre", "Unknown")
75 STORE(songSCID + "_ipfs", ipfsHash)
80 IF previewArtCid == "" THEN GOTO 90
85 STORE(songSCID + "_preview_art_cid", previewArtCid)
90 STORE(songSCID + "_upvotes", 0)
91 STORE(songSCID + "_timestamp", BLOCK_TIMESTAMP())
92 STORE("total_songs", count + 1)
98 RETURN 0
99 RETURN 1
End Function
Function UpvoteSong(songSCID String) Uint64
10 IF EXISTS(ADDRESS_STRING(SIGNER()) + "_upvoted_" + songSCID) THEN GOTO 99
20 IF EXISTS(songSCID + "_registered") THEN GOTO 40
30 RETURN 1
40 DIM upvotes as Uint64
50 LET upvotes = LOAD(songSCID + "_upvotes") + 1
60 STORE(songSCID + "_upvotes", upvotes)
70 STORE(ADDRESS_STRING(SIGNER()) + "_upvoted_" + songSCID, 1)
98 RETURN 0
99 RETURN 1
End Function
Function RemoveSong(songSCID String) Uint64
10 IF LOAD("owner") == ADDRESS_STRING(SIGNER()) THEN GOTO 30
20 RETURN 1
30 IF EXISTS(songSCID + "_registered") THEN GOTO 50
40 RETURN 1
50 STORE(songSCID + "_removed", 1)
60 STORE(songSCID + "_removed_at", BLOCK_TIMESTAMP())
98 RETURN 0
End Function
Function TransferOwnership(newOwner String) Uint64
10 IF LOAD("owner") == ADDRESS_STRING(SIGNER()) THEN GOTO 30
20 RETURN 1
30 IF newOwner == "" THEN GOTO 99
40 STORE("owner", newOwner)
98 RETURN 0
99 RETURN 1
End Function
Function GetTotalSongs() Uint64
10 RETURN LOAD("total_songs")
End Function
Function GetSong(index Uint64) String
10 IF EXISTS("song_" + index) THEN GOTO 30
20 RETURN ""
30 RETURN LOAD("song_" + index)
End Function |
| SC Arguments: [Name:SC_ACTION Type:uint64 Value:'1' Name:SC_CODE Type:string Value:'// DeroBeats Registry — MV4 (minimal v4)
// Return codes: 0=ok 1=error
Function Initialize() Uint64
10 IF EXISTS("owner") THEN GOTO 99
20 STORE("owner", ADDRESS_STRING(SIGNER()))
30 STORE("total_songs", 0)
40 STORE("platform_name", "DeroBeats")
50 STORE("platform_url", "derobeats.tela")
60 STORE("var_header_name", "DeroBeats Registry MV4")
61 STORE("var_header_description", "Minimal song registry for DeroBeats.")
62 STORE("var_header_icon", "")
98 RETURN 0
99 RETURN 1
End Function
Function RegisterSong(songSCID String, title String, artist String, genre String, ipfsHash String, previewArtCid String) Uint64
10 IF EXISTS(ADDRESS_STRING(SIGNER())) THEN GOTO 12
11 STORE(ADDRESS_STRING(SIGNER()), 1)
12 IF songSCID == "" THEN GOTO 99
15 IF title == "" THEN GOTO 99
20 IF artist == "" THEN GOTO 99
25 IF EXISTS(songSCID + "_registered") THEN GOTO 99
30 DIM count as Uint64
35 LET count = LOAD("total_songs")
40 STORE("song_" + count, songSCID)
45 STORE(songSCID + "_registered", 1)
50 STORE(songSCID + "_title", title)
55 STORE(songSCID + "_artist", artist)
60 STORE(songSCID + "_artist_addr", ADDRESS_STRING(SIGNER()))
65 IF genre == "" THEN GOTO 70
68 STORE(songSCID + "_genre", genre)
69 GOTO 75
70 STORE(songSCID + "_genre", "Unknown")
75 STORE(songSCID + "_ipfs", ipfsHash)
80 IF previewArtCid == "" THEN GOTO 90
85 STORE(songSCID + "_preview_art_cid", previewArtCid)
90 STORE(songSCID + "_upvotes", 0)
91 STORE(songSCID + "_timestamp", BLOCK_TIMESTAMP())
92 STORE("total_songs", count + 1)
98 RETURN 0
99 RETURN 1
End Function
Function UpvoteSong(songSCID String) Uint64
10 IF EXISTS(ADDRESS_STRING(SIGNER()) + "_upvoted_" + songSCID) THEN GOTO 99
20 IF EXISTS(songSCID + "_registered") THEN GOTO 40
30 RETURN 1
40 DIM upvotes as Uint64
50 LET upvotes = LOAD(songSCID + "_upvotes") + 1
60 STORE(songSCID + "_upvotes", upvotes)
70 STORE(ADDRESS_STRING(SIGNER()) + "_upvoted_" + songSCID, 1)
98 RETURN 0
99 RETURN 1
End Function
Function RemoveSong(songSCID String) Uint64
10 IF LOAD("owner") == ADDRESS_STRING(SIGNER()) THEN GOTO 30
20 RETURN 1
30 IF EXISTS(songSCID + "_registered") THEN GOTO 50
40 RETURN 1
50 STORE(songSCID + "_removed", 1)
60 STORE(songSCID + "_removed_at", BLOCK_TIMESTAMP())
98 RETURN 0
End Function
Function TransferOwnership(newOwner String) Uint64
10 IF LOAD("owner") == ADDRESS_STRING(SIGNER()) THEN GOTO 30
20 RETURN 1
30 IF newOwner == "" THEN GOTO 99
40 STORE("owner", newOwner)
98 RETURN 0
99 RETURN 1
End Function
Function GetTotalSongs() Uint64
10 RETURN LOAD("total_songs")
End Function
Function GetSong(index Uint64) String
10 IF EXISTS("song_" + index) THEN GOTO 30
20 RETURN ""
30 RETURN LOAD("song_" + index)
End Function'] |