SC CODE:
Function InitializePrivate() Uint64
01 DIM txid, test owner as String
02 LET txid = TXID()
03 LET owner = SIGNER()
20 STORE(txid, owner) // Owner excutors the transfers unless customer & merchant both agree to sign contract early.
21 STORE(txid+ "_commission_dero_address", "dero1qy4fxqwqrwmsny5uuypwyh5rhhdzglr3ylx77sglhzr5klmyqya36qgvmh5k2")
22 STORE(txid+ "_order_id", "")
23 STORE(txid+ "_dero_amount", 0)
24 STORE(txid+ "_commission", 500)
25 STORE(txid+ "_merchant_dero_address", "")
26 STORE(txid+ "_customer_dero_address", "")
27 STORE(txid+ "_sign_customer_agreement", 0) // 0 = Not Signed, 1 = Signed
28 STORE(txid+ "_sign_merchant_agreement", 0) // 0 = Not Signed, 1 = Signed
29 STORE(txid+ "_status", 0)
9999 RETURN PrintInformation("Successful Initialization of Contract " + txid)
End Function
// Check if customer is serious about contract setup.
Function CheckAddress(address String) Uint64
01 DIM value as Uint64
02 DIM printString as String
03 LET value = 1
04 LET printString = address
06 PRINTF "%s" address
07 PRINTF "%s" IS_ADDRESS_VALID(printString)
10 IF IS_ADDRESS_VALID(printString) == 1 THEN GOTO 20
11 value = 0
20 PRINTF "%s" value
22 RETURN value
End Function
Function CreateSmartContract(order_id String, customer_dero_address String, merchant_dero_address String, dero_amount Uint64, commission Uint64, dero_humable String) Uint64
01 DIM txid, owner, signer, as String
02 DIM amount, fee, sign_customer, sign_merchant as Uint64
03 LET txid = TXID()
04 LET owner = LOAD(txid)
05 LET signer = SIGNER()
06 LET sign_customer = LOAD(txid + "_sign_customer_agreement")
07 LET sign_merchant = LOAD(txid + "_sign_merchant_agreement")
41 IF owner == signer THEN GOTO 50
42 RETURN PrintError("Error: You cannot assign the Smart Contract Details :Error")
50 STORE(txid+"_order_id", order_id)
51 STORE(txid+"_dero_amount", amount)
52 STORE(txid+"_commission", commission)
53 STORE(txid+ "_dero_humable", dero_humable)
54 IF sign_customer == 0 THEN GOTO 60
55 PrintError("Customer has signed agreement already, cannot force change of their dero address.")
60 STORE(txid+"_customer_dero_address", customer_dero_address)
61 IF sign_merchant == 0 THEN GOTO 70
62 PrintError("Merchant has signed agreement already, cannot force change of their dero address.")
70 STORE(txid+"_merchant_dero_address", merchant_dero_address)
110 PrintContactDetails()
9999 RETURN PrintInformation("Contract has been deployed... Customer needs to despiot and sign...")
End Function
/*
Customer will need to login into the site, can view contract agreement on from the site or use the curl
command view the agreement. Once you see that order details are correct and your dero address matches the wallet.
*/
Function CustomerDepositAndSignContract(wallet String) Uint64
01 DIM txid, owner, dero_address, signer, as String
02 DIM amount, fee, sign_customer as Uint64
03 LET txid = TXID()
04 LET owner = LOAD(txid)
05 LET signer = SIGNER()
06 LET sign_customer = LOAD(txid + "_sign_customer_agreement")
07 LET amount = LOAD(txid + "_dero_amount")
// 10 LET dero_address = ADDRESS_RAW(owner)
10 LET dero_address = owner
20 PRINTF "%s" dero_address
30 IF ADDRESS_RAW(LOAD(txid + "_customer_dero_address")) == signer THEN GOTO 40
// 30 IF LOAD(txid + "_customer_dero_address") != signer THEN GOTO 40
// 30 IF LOAD(txid + "_customer_dero_address") == signer THEN GOTO 40
31 RETURN PrintError("You are not authorized to do this.")
40 IF sign_customer == 0 THEN GOTO 50
41 RETURN PrintError("Looks like you have sign the agreement already. Going to check if existing balance is in blockchain...")
50 SEND_DERO_TO_ADDRESS(owner, amount) // Desposit Money into Dero Smart Contract Wallet.
51 STORE(txid + "_sign_customer_agreement", 1)
52 PrintInformation("Customer has agreed to the contract. Money is now sitting inside the smart contract.")
9999 RETURN 0
End Function
Function ExcuteContractTransfers() Uint64
01 DIM txid, owner, signer, commission_address, merchant_address as String
02 DIM sign_customer, agent_fee, merchant_funds, sign_merchant, comission, dero_amount as Uint64
03 LET txid = TXID()
04 LET owner = LOAD(txid)
05 LET signer = SIGNER()
06 LET sign_customer = LOAD(txid + "_sign_customer_agreement")
07 LET sign_merchant = LOAD(txid + "_sign_merchant_agreement")
10 LET commission_address = ADDRESS_RAW(LOAD(txid + "_commission_dero_address"))
11 LET merchant_address = ADDRESS_RAW(LOAD(txid + "_merchant_dero_address"))
12 LET dero_amount = LOAD(txid + "_dero_amount")
13 LET comission = LOAD(txid + "_commission")
14 PRINTF "%s" commission_address
20 IF owner == signer THEN GOTO 50
21 RETURN PrintErrorwallet("You are not authorized to do this.")
50 IF sign_customer == 1 && sign_merchant == 1 THEN GOTO 52 // Once both parties agree, dero addresses are locked in and cannot be changed.
51 RETURN PrintError("You cannot excute funds transfers yet. Let's see who hasn't signed up yet: Merchant Status: " + sign_merchant + " Customer Status: " + sign_customer)
52 LET merchant_funds = dero_amount - comission
60 SEND_DERO_TO_ADDRESS(commission_address, comission) // Desposit Money into Dero Smart Contract Wallet.
90 SEND_DERO_TO_ADDRESS(merchant_address, merchant_funds)
100 STORE(txid+ "_status", 1) // Completed
// 90
9999 RETURN PrintInformation("Contract has been fullfiled.")
End Function
Function MerchantSignsContract() Uint64
01 DIM txid, owner, signer, as String
02 DIM sign_merchant as Uint64
03 LET txid = TXID()
04 LET owner = LOAD(txid)
05 LET signer = SIGNER()
06 LET sign_merchant = LOAD(txid + "_sign_merchant_agreement")
10 IF sign_merchant == 0 THEN GOTO 20
11 RETURN PrintError("You have already signed this agreed.")
20 IF owner == signer THEN GOTO 50
21 RETURN PrintError("You are not authorized to sign this contract.")
50 STORE(txid+"_sign_merchant_agreement", 1) // Completed
9999 RETURN PrintInformation("You have successful signed the contract agreement.")
End Function
Function PrintError(error_message String) Uint64
01 DIM wallet, scid, owner, order_id signer as String
02 LET wallet = TXID()
03 LET owner = LOAD(wallet)
04 LET order_id = LOAD(wallet+"_order_id")
05 LET scid = SCID()
10 PRINTF ""
20 PRINTF " #########################################[ ERROR ]############################"
30 PRINTF " # Dero Smart Contract #"
40 PRINTF " # #"
50 PRINTF " # %s" error_message
60 PRINTF " # #"
70 PRINTF " #-----------------------------------------[ ERROR ]---------------------------"
80 PRINTF " # TXID: %s" wallet
90 PRINTF " # Order-ID: %s" order_id
91 PRINTF " # SC-ID: %s" scid
100 PRINTF " ##############################################################################"
9999 RETURN 0
End Function
Function PrintContactDetails() Uint64
01 DIM txid, scid, owner, order_id, dero_amount, customer_dero_address, amount merchant_dero_address, signer as String
02 DIM commission as Uint64
03 LET txid = TXID()
04 LET owner = LOAD(txid)
05 LET order_id = LOAD(txid+"_order_id")
06 LET customer_dero_address = LOAD(txid+"_customer_dero_address")
07 LET merchant_dero_address = LOAD(txid+"_merchant_dero_address")
10 LET dero_amount = LOAD(txid+"_dero_humable")
12 LET scid = SCID()
30 PRINTF ""
40 PRINTF " ############################################################################## "
50 PRINTF " # Dero Smart Contract # "
61 PRINTF " # # "
72 PRINTF " # Please confirm if the following details are correct. # "
73 PRINTF " # Once you have agreed to the contract, no changes can be made to your Dero # "
74 PRINTF " # address. # "
80 PRINTF " #----------------------------------------------------------------------------# "
90 PRINTF " # TXID: %s" txid
91 PRINTF " # SC-ID: %s" scid
92 PRINTF " # Order-ID: %s" order_id
93 PRINTF " # # "
94 PRINTF " # Customer Dero Address: %s" customer_dero_address
95 PRINTF " # Merchant Dero Address: %s" merchant_dero_address
96 PRINTF " # # "
97 PRINTF " # Dero Amount: %s" dero_amount
99 PRINTF " # # "
100 PRINTF " ############################################################################## "
110 PRINT ""
9999 RETURN 0
End Function
Function PrintInformation(information_message String) Uint64
01 DIM wallet, owner, scid order_id signer as String
02 LET wallet = TXID()
03 LET owner = LOAD(wallet)
04 LET order_id = LOAD(wallet + "_order_id")
05 LET scid = SCID()
10 PRINTF ""
20 PRINTF " ############################################################################## "
30 PRINTF " # Dero Smart Contract # "
40 PRINTF " # # "
50 PRINTF " # %s" information_message
60 PRINTF " # # "
70 PRINTF " #----------------------------------------------------------------------------# "
80 PRINTF " # TX-ID: %s" wallet
81 PRINTF " # SC-ID: %s" scid
90 PRINTF " # Order-ID: %s" order_id
100 PRINTF " ############################################################################## "
110 PRINT ""
9999 RETURN 0
End Function
|
SC Arguments: [Name:SC_ACTION Type:uint64 Value:'1' Name:SC_CODE Type:string Value:'
Function InitializePrivate() Uint64
01 DIM txid, test owner as String
02 LET txid = TXID()
03 LET owner = SIGNER()
20 STORE(txid, owner) // Owner excutors the transfers unless customer & merchant both agree to sign contract early.
21 STORE(txid+ "_commission_dero_address", "dero1qy4fxqwqrwmsny5uuypwyh5rhhdzglr3ylx77sglhzr5klmyqya36qgvmh5k2")
22 STORE(txid+ "_order_id", "")
23 STORE(txid+ "_dero_amount", 0)
24 STORE(txid+ "_commission", 500)
25 STORE(txid+ "_merchant_dero_address", "")
26 STORE(txid+ "_customer_dero_address", "")
27 STORE(txid+ "_sign_customer_agreement", 0) // 0 = Not Signed, 1 = Signed
28 STORE(txid+ "_sign_merchant_agreement", 0) // 0 = Not Signed, 1 = Signed
29 STORE(txid+ "_status", 0)
9999 RETURN PrintInformation("Successful Initialization of Contract " + txid)
End Function
// Check if customer is serious about contract setup.
Function CheckAddress(address String) Uint64
01 DIM value as Uint64
02 DIM printString as String
03 LET value = 1
04 LET printString = address
06 PRINTF "%s" address
07 PRINTF "%s" IS_ADDRESS_VALID(printString)
10 IF IS_ADDRESS_VALID(printString) == 1 THEN GOTO 20
11 value = 0
20 PRINTF "%s" value
22 RETURN value
End Function
Function CreateSmartContract(order_id String, customer_dero_address String, merchant_dero_address String, dero_amount Uint64, commission Uint64, dero_humable String) Uint64
01 DIM txid, owner, signer, as String
02 DIM amount, fee, sign_customer, sign_merchant as Uint64
03 LET txid = TXID()
04 LET owner = LOAD(txid)
05 LET signer = SIGNER()
06 LET sign_customer = LOAD(txid + "_sign_customer_agreement")
07 LET sign_merchant = LOAD(txid + "_sign_merchant_agreement")
41 IF owner == signer THEN GOTO 50
42 RETURN PrintError("Error: You cannot assign the Smart Contract Details :Error")
50 STORE(txid+"_order_id", order_id)
51 STORE(txid+"_dero_amount", amount)
52 STORE(txid+"_commission", commission)
53 STORE(txid+ "_dero_humable", dero_humable)
54 IF sign_customer == 0 THEN GOTO 60
55 PrintError("Customer has signed agreement already, cannot force change of their dero address.")
60 STORE(txid+"_customer_dero_address", customer_dero_address)
61 IF sign_merchant == 0 THEN GOTO 70
62 PrintError("Merchant has signed agreement already, cannot force change of their dero address.")
70 STORE(txid+"_merchant_dero_address", merchant_dero_address)
110 PrintContactDetails()
9999 RETURN PrintInformation("Contract has been deployed... Customer needs to despiot and sign...")
End Function
/*
Customer will need to login into the site, can view contract agreement on from the site or use the curl
command view the agreement. Once you see that order details are correct and your dero address matches the wallet.
*/
Function CustomerDepositAndSignContract(wallet String) Uint64
01 DIM txid, owner, dero_address, signer, as String
02 DIM amount, fee, sign_customer as Uint64
03 LET txid = TXID()
04 LET owner = LOAD(txid)
05 LET signer = SIGNER()
06 LET sign_customer = LOAD(txid + "_sign_customer_agreement")
07 LET amount = LOAD(txid + "_dero_amount")
// 10 LET dero_address = ADDRESS_RAW(owner)
10 LET dero_address = owner
20 PRINTF "%s" dero_address
30 IF ADDRESS_RAW(LOAD(txid + "_customer_dero_address")) == signer THEN GOTO 40
// 30 IF LOAD(txid + "_customer_dero_address") != signer THEN GOTO 40
// 30 IF LOAD(txid + "_customer_dero_address") == signer THEN GOTO 40
31 RETURN PrintError("You are not authorized to do this.")
40 IF sign_customer == 0 THEN GOTO 50
41 RETURN PrintError("Looks like you have sign the agreement already. Going to check if existing balance is in blockchain...")
50 SEND_DERO_TO_ADDRESS(owner, amount) // Desposit Money into Dero Smart Contract Wallet.
51 STORE(txid + "_sign_customer_agreement", 1)
52 PrintInformation("Customer has agreed to the contract. Money is now sitting inside the smart contract.")
9999 RETURN 0
End Function
Function ExcuteContractTransfers() Uint64
01 DIM txid, owner, signer, commission_address, merchant_address as String
02 DIM sign_customer, agent_fee, merchant_funds, sign_merchant, comission, dero_amount as Uint64
03 LET txid = TXID()
04 LET owner = LOAD(txid)
05 LET signer = SIGNER()
06 LET sign_customer = LOAD(txid + "_sign_customer_agreement")
07 LET sign_merchant = LOAD(txid + "_sign_merchant_agreement")
10 LET commission_address = ADDRESS_RAW(LOAD(txid + "_commission_dero_address"))
11 LET merchant_address = ADDRESS_RAW(LOAD(txid + "_merchant_dero_address"))
12 LET dero_amount = LOAD(txid + "_dero_amount")
13 LET comission = LOAD(txid + "_commission")
14 PRINTF "%s" commission_address
20 IF owner == signer THEN GOTO 50
21 RETURN PrintErrorwallet("You are not authorized to do this.")
50 IF sign_customer == 1 && sign_merchant == 1 THEN GOTO 52 // Once both parties agree, dero addresses are locked in and cannot be changed.
51 RETURN PrintError("You cannot excute funds transfers yet. Let's see who hasn't signed up yet: Merchant Status: " + sign_merchant + " Customer Status: " + sign_customer)
52 LET merchant_funds = dero_amount - comission
60 SEND_DERO_TO_ADDRESS(commission_address, comission) // Desposit Money into Dero Smart Contract Wallet.
90 SEND_DERO_TO_ADDRESS(merchant_address, merchant_funds)
100 STORE(txid+ "_status", 1) // Completed
// 90
9999 RETURN PrintInformation("Contract has been fullfiled.")
End Function
Function MerchantSignsContract() Uint64
01 DIM txid, owner, signer, as String
02 DIM sign_merchant as Uint64
03 LET txid = TXID()
04 LET owner = LOAD(txid)
05 LET signer = SIGNER()
06 LET sign_merchant = LOAD(txid + "_sign_merchant_agreement")
10 IF sign_merchant == 0 THEN GOTO 20
11 RETURN PrintError("You have already signed this agreed.")
20 IF owner == signer THEN GOTO 50
21 RETURN PrintError("You are not authorized to sign this contract.")
50 STORE(txid+"_sign_merchant_agreement", 1) // Completed
9999 RETURN PrintInformation("You have successful signed the contract agreement.")
End Function
Function PrintError(error_message String) Uint64
01 DIM wallet, scid, owner, order_id signer as String
02 LET wallet = TXID()
03 LET owner = LOAD(wallet)
04 LET order_id = LOAD(wallet+"_order_id")
05 LET scid = SCID()
10 PRINTF ""
20 PRINTF " #########################################[ ERROR ]############################"
30 PRINTF " # Dero Smart Contract #"
40 PRINTF " # #"
50 PRINTF " # %s" error_message
60 PRINTF " # #"
70 PRINTF " #-----------------------------------------[ ERROR ]---------------------------"
80 PRINTF " # TXID: %s" wallet
90 PRINTF " # Order-ID: %s" order_id
91 PRINTF " # SC-ID: %s" scid
100 PRINTF " ##############################################################################"
9999 RETURN 0
End Function
Function PrintContactDetails() Uint64
01 DIM txid, scid, owner, order_id, dero_amount, customer_dero_address, amount merchant_dero_address, signer as String
02 DIM commission as Uint64
03 LET txid = TXID()
04 LET owner = LOAD(txid)
05 LET order_id = LOAD(txid+"_order_id")
06 LET customer_dero_address = LOAD(txid+"_customer_dero_address")
07 LET merchant_dero_address = LOAD(txid+"_merchant_dero_address")
10 LET dero_amount = LOAD(txid+"_dero_humable")
12 LET scid = SCID()
30 PRINTF ""
40 PRINTF " ############################################################################## "
50 PRINTF " # Dero Smart Contract # "
61 PRINTF " # # "
72 PRINTF " # Please confirm if the following details are correct. # "
73 PRINTF " # Once you have agreed to the contract, no changes can be made to your Dero # "
74 PRINTF " # address. # "
80 PRINTF " #----------------------------------------------------------------------------# "
90 PRINTF " # TXID: %s" txid
91 PRINTF " # SC-ID: %s" scid
92 PRINTF " # Order-ID: %s" order_id
93 PRINTF " # # "
94 PRINTF " # Customer Dero Address: %s" customer_dero_address
95 PRINTF " # Merchant Dero Address: %s" merchant_dero_address
96 PRINTF " # # "
97 PRINTF " # Dero Amount: %s" dero_amount
99 PRINTF " # # "
100 PRINTF " ############################################################################## "
110 PRINT ""
9999 RETURN 0
End Function
Function PrintInformation(information_message String) Uint64
01 DIM wallet, owner, scid order_id signer as String
02 LET wallet = TXID()
03 LET owner = LOAD(wallet)
04 LET order_id = LOAD(wallet + "_order_id")
05 LET scid = SCID()
10 PRINTF ""
20 PRINTF " ############################################################################## "
30 PRINTF " # Dero Smart Contract # "
40 PRINTF " # # "
50 PRINTF " # %s" information_message
60 PRINTF " # # "
70 PRINTF " #----------------------------------------------------------------------------# "
80 PRINTF " # TX-ID: %s" wallet
81 PRINTF " # SC-ID: %s" scid
90 PRINTF " # Order-ID: %s" order_id
100 PRINTF " ############################################################################## "
110 PRINT ""
9999 RETURN 0
End Function
'] |