Skip to content
Smart-Contract Paywall running on the Dero Virtual Machine to protect your website
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
system Update admin.php Apr 9, 2019
README.md Create README.md Apr 4, 2019
paywall.bas Add files via upload Apr 4, 2019

README.md

DVM Paywall

Introduction

The contract is designed to be a paywall on webservers. The user can signup, extend the membership and change the password via CURL. Executing the CURL commands will later hopefully be possible in webwallet, this would be the easiest way for endusers.

Important: You always have to use the same (sub)address when interacting with the smart contract. Even if you loose your password, you can set a new password as long as you have access to your (sub)address!

The contract owner can deactivate/reactivate users and change the status and target topoheight (til when access is granted). Of course there are some other features like withdraw, change contract owner, change the factor for calculating the target topoheight and freezing the signup.

There must be a fully synced command line daemon running on the webserver (highly recommended) or you can even use a remote node without installing anything but the php scripts on your server to run the paywall.

Demo

Please check out the demo before you install the paywall!

Setup

Make sure wallet is running (and connected/synced to deamon) on 127.0.0.1:30309

Install paywall.bas from command line. The returned transaction id is also your smart contract id.

curl --request POST --data-binary @paywall.bas http://127.0.0.1:30309/install_sc

Copy the system folder to a public folder on your webserver.

Open "dvm-paywall-start.php" with a text editor.
Change "$dvm_paywall_scid" to your smart contract id.
Change "$dvm_paywall_salt" to your salt. The salt can be whatever you want, but keep it secret!

Open https://your.server/path/signup.php with your webbrowser. Enter a small amount and fill out the password fields. Run the generated CURL with your admin wallet.

If no error occurs, you can be sure the smart contract is working correct and the system is now ready to be used.

Go to https://your.server/path/dvm-paywall-admin/login.php, enter your password (your address is already stored as contract owner) to test the admin area.

Go to https://your.server/path/login.php and enter your address and password to test the member area.

CURL Samples Signer

Signup:

curl -X POST http://127.0.0.1:30309/json_rpc -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"0","method":"transfer_split","params":{"mixin":5,"get_tx_key": true , "sc_tx":{"entrypoint":"Signup","scid":"baf924e5897da796e1412135f760cabc5654af21ecb3682b1c086549e995540e", "value":1230000000000, "params":{ "hash":"3cca0bdd4ca98e2fbc66f656eda765fd5a15fce804b9b04a573dfaa5eebe70d9" }}}}' 

Extend Membership:

curl -X POST http://127.0.0.1:30309/json_rpc -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"0","method":"transfer_split","params":{"mixin":5,"get_tx_key": true , "sc_tx":{"entrypoint":"Extend","scid":"baf924e5897da796e1412135f760cabc5654af21ecb3682b1c086549e995540e", "value":1230000000000}}}' 

Change Password:

curl -X POST http://127.0.0.1:30309/json_rpc -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"0","method":"transfer_split","params":{"mixin":5,"get_tx_key": true , "sc_tx":{"entrypoint":"ChangeHash","scid":"baf924e5897da796e1412135f760cabc5654af21ecb3682b1c086549e995540e", "params":{ "hash":"3cca0bdd4ca98e2fbc66f656eda765fd5a15fce804b9b04a573dfaa5eebe70d9" }}}}' 

CURL Samples Owner

Deactivate Account:

curl -X POST http://127.0.0.1:30309/json_rpc -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"0","method":"transfer_split","params":{"mixin":5,"get_tx_key": true , "sc_tx":{"entrypoint":"Deactivate","scid":"baf924e5897da796e1412135f760cabc5654af21ecb3682b1c086549e995540e", "params":{ "userid":"dERoUQMpeqgTNGKfBooQdwTAaYwR7sZVggfdBut8DmkmZ97aYi8h3NH3ZexsKtbY4pHswEgRpB4kvWsvyazbxVk91o5KJ6McZ4" }}}}' 

Reactive Account:

curl -X POST http://127.0.0.1:30309/json_rpc -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"0","method":"transfer_split","params":{"mixin":5,"get_tx_key": true , "sc_tx":{"entrypoint":"Reactivate","scid":"baf924e5897da796e1412135f760cabc5654af21ecb3682b1c086549e995540e", "params":{ "userid":"dERoUQMpeqgTNGKfBooQdwTAaYwR7sZVggfdBut8DmkmZ97aYi8h3NH3ZexsKtbY4pHswEgRpB4kvWsvyazbxVk91o5KJ6McZ4" }}}}' 

Withdraw:

curl -X POST http://127.0.0.1:30309/json_rpc -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"0","method":"transfer_split","params":{"mixin":5,"get_tx_key": true , "sc_tx":{"entrypoint":"Withdraw","scid":"baf924e5897da796e1412135f760cabc5654af21ecb3682b1c086549e995540e", "params":{ "amount":"1230000000000" }}}}' 

Transfer Ownership:

curl -X POST http://127.0.0.1:30309/json_rpc -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"0","method":"transfer_split","params":{"mixin":5,"get_tx_key": true , "sc_tx":{"entrypoint":"TransferOwnership","scid":"baf924e5897da796e1412135f760cabc5654af21ecb3682b1c086549e995540e", "params":{ "newowner":"dERoUQMpeqgTNGKfBooQdwTAaYwR7sZVggfdBut8DmkmZ97aYi8h3NH3ZexsKtbY4pHswEgRpB4kvWsvyazbxVk91o5KJ6McZ4" }}}}' 

Claim Ownership:

curl -X POST http://127.0.0.1:30309/json_rpc -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"0","method":"transfer_split","params":{"mixin":5,"get_tx_key": true , "sc_tx":{"entrypoint":"ClaimOwnership","scid":"baf924e5897da796e1412135f760cabc5654af21ecb3682b1c086549e995540e"}}}' 

Change Factor:

curl -X POST http://127.0.0.1:30309/json_rpc -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"0","method":"transfer_split","params":{"mixin":5,"get_tx_key": true , "sc_tx":{"entrypoint":"OverrideFactor","scid":"baf924e5897da796e1412135f760cabc5654af21ecb3682b1c086549e995540e", "params":{ "factor":"10000000000" }}}}' 

Set Counter:

curl -X POST http://127.0.0.1:30309/json_rpc -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"0","method":"transfer_split","params":{"mixin":5,"get_tx_key": true , "sc_tx":{"entrypoint":"OverrideCount","scid":"baf924e5897da796e1412135f760cabc5654af21ecb3682b1c086549e995540e", "params":{ "count":"123" }}}}' 

Freeze/Unfreeze Signup:

curl -X POST http://127.0.0.1:30309/json_rpc -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"0","method":"transfer_split","params":{"mixin":5,"get_tx_key": true , "sc_tx":{"entrypoint":"ChangeFreeze","scid":"baf924e5897da796e1412135f760cabc5654af21ecb3682b1c086549e995540e"}}}' 

Override Hash:

curl -X POST http://127.0.0.1:30309/json_rpc -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"0","method":"transfer_split","params":{"mixin":5,"get_tx_key": true , "sc_tx":{"entrypoint":"OverrideHash","scid":"baf924e5897da796e1412135f760cabc5654af21ecb3682b1c086549e995540e", "params":{ "userid":"dERoUQMpeqgTNGKfBooQdwTAaYwR7sZVggfdBut8DmkmZ97aYi8h3NH3ZexsKtbY4pHswEgRpB4kvWsvyazbxVk91o5KJ6McZ4","hash":"3cca0bdd4ca98e2fbc66f656eda765fd5a15fce804b9b04a573dfaa5eebe70d9" }}}}' 

Override Topo:

curl -X POST http://127.0.0.1:30309/json_rpc -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"0","method":"transfer_split","params":{"mixin":5,"get_tx_key": true , "sc_tx":{"entrypoint":"OverrideTopo","scid":"baf924e5897da796e1412135f760cabc5654af21ecb3682b1c086549e995540e", "params":{ "userid":"dERoUQMpeqgTNGKfBooQdwTAaYwR7sZVggfdBut8DmkmZ97aYi8h3NH3ZexsKtbY4pHswEgRpB4kvWsvyazbxVk91o5KJ6McZ4","topo":"12345" }}}}' 

Override Status:

curl -X POST http://127.0.0.1:30309/json_rpc -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"0","method":"transfer_split","params":{"mixin":5,"get_tx_key": true , "sc_tx":{"entrypoint":"OverrideStatus","scid":"baf924e5897da796e1412135f760cabc5654af21ecb3682b1c086549e995540e", "params":{ "userid":"dERoUQMpeqgTNGKfBooQdwTAaYwR7sZVggfdBut8DmkmZ97aYi8h3NH3ZexsKtbY4pHswEgRpB4kvWsvyazbxVk91o5KJ6McZ4","status":"3" }}}}' 
You can’t perform that action at this time.