Skip to content

Commit

Permalink
Add KiiChain testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
nescampos committed Aug 19, 2024
1 parent 5ecd88e commit 25739ea
Show file tree
Hide file tree
Showing 3 changed files with 330 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Demo with Etherlink: https://monetizado.github.io/demosmonetizado/demo_etherlink.html
- Demo with Filecoin: https://monetizado.github.io/demosmonetizado/demo_filecoin.html
- Demo with Fuse: https://monetizado.github.io/demosmonetizado/demo_fuse.html
- Demo with KiiChain: https://monetizado.github.io/demosmonetizado/demo_kiichain.html
- Demo with Linea: https://monetizado.github.io/demosmonetizado/demo_linea.html
- Demo with Lisk: https://monetizado.github.io/demosmonetizado/demo_lisk.html
- Demo with Meter: https://monetizado.github.io/demosmonetizado/demo_meter.html
Expand Down
328 changes: 328 additions & 0 deletions demo_kiichain.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,328 @@
<!DOCTYPE html>
<html lang="en">

<head>

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">

<title>Monetizado demo - KiiChain</title>

<!-- Custom fonts for this template-->
<link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
<link
href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i"
rel="stylesheet">

<!-- Custom styles for this template-->
<link href="css/sb-admin-2.min.css" rel="stylesheet">


<link rel="monetizado" href="kii:testnet://0xda3ec0b8bddd2e8bdedede3333fbaf938fcc18c5/0" />

</head>

<body id="page-top">

<!-- Page Wrapper -->
<div id="wrapper">

<!-- Sidebar -->
<ul class="navbar-nav bg-gradient-primary sidebar sidebar-dark accordion" id="accordionSidebar">

<!-- Sidebar - Brand -->
<a class="sidebar-brand d-flex align-items-center justify-content-center" href="index.html">
<div class="sidebar-brand-icon rotate-n-15">
<i class="fas fa-laugh-wink"></i>
</div>
<div class="sidebar-brand-text mx-3">Monetizado demo - KiiChain</div>
</a>

<!-- Divider -->
<hr class="sidebar-divider my-0">

<!-- Nav Item - Dashboard -->
<li class="nav-item active">
<a class="nav-link" href="demo.html">
<i class="fas fa-fw fa-tachometer-alt"></i>
<span>Demo 1</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://github.com/Monetizado">
<i class="fas fa-fw fa-file-image-o"></i>
<span>Go to github</span></a>
</li>

<!-- Divider -->
<hr class="sidebar-divider d-none d-md-block">

<!-- Sidebar Toggler (Sidebar) -->
<div class="text-center d-none d-md-inline">
<button class="rounded-circle border-0" id="sidebarToggle"></button>
</div>

</ul>
<!-- End of Sidebar -->

<!-- Content Wrapper -->
<div id="content-wrapper" class="d-flex flex-column">

<!-- Main Content -->
<div id="content">

<!-- Topbar -->
<nav class="navbar navbar-expand navbar-light bg-white topbar mb-4 static-top shadow">

<!-- Sidebar Toggle (Topbar) -->
<button id="sidebarToggleTop" class="btn btn-link d-md-none rounded-circle mr-3">
<i class="fa fa-bars"></i>
</button>


<!-- Topbar Navbar -->
<ul class="navbar-nav ml-auto">

<!-- Nav Item - Search Dropdown (Visible Only XS) -->
<li class="nav-item dropdown no-arrow d-sm-none">
<a class="nav-link dropdown-toggle" href="#" id="searchDropdown" role="button"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fas fa-search fa-fw"></i>
</a>
<!-- Dropdown - Messages -->
<div class="dropdown-menu dropdown-menu-right p-3 shadow animated--grow-in"
aria-labelledby="searchDropdown">
<form class="form-inline mr-auto w-100 navbar-search">
<div class="input-group">
<input type="text" class="form-control bg-light border-0 small"
placeholder="Search for..." aria-label="Search"
aria-describedby="basic-addon2">
<div class="input-group-append">
<button class="btn btn-primary" type="button">
<i class="fas fa-search fa-sm"></i>
</button>
</div>
</div>
</form>
</div>
</li>



<div class="topbar-divider d-none d-sm-block"></div>

<!-- Nav Item - User Information -->
<li class="nav-item dropdown no-arrow">
<a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<img class="img-profile rounded-circle"
src="img/undraw_profile.svg">
</a>

</li>

</ul>

</nav>
<!-- End of Topbar -->

<!-- Begin Page Content -->
<div class="container-fluid">

<!-- Page Heading -->
<div class="d-sm-flex align-items-center justify-content-between mb-4">
<h1 class="h3 mb-0 text-gray-800">Protected Content</h1>
</div>
<!-- Content Row -->

<div class="row">

<!-- Area Chart -->
<div class="col-xl-8 col-lg-7">

<div class="card shadow mb-4">
<!-- Card Header - Dropdown -->
<div
class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
<h6 class="m-0 font-weight-bold text-primary">This page is monetized thanks to Monetizado</h6>

</div>
<!-- Card Body -->
<div class="card-body my_clubs">
<div id="contenido">
The content URI for this content is <b id="monetizadopointer"></b>
</div>

</div>
</div>

<div class="card shadow mb-4">
<!-- Card Header - Dropdown -->
<div
class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
<h6 class="m-0 font-weight-bold text-primary">This page is exclusive for subscriptors</h6>

</div>
<!-- Card Body -->
<div class="card-body my_clubs">
<div id="protected-content">
This content is protected, just for subscriptors.

To get access to the exclusive content, you need to pay: <span id="amountToPay"></span>

<button id="payBtn" onclick="payForAccess()">Pay and access</button>
</div>
<div id="exclusive-content">
You paid, and you have access for this exclusive content.
</div>
</div>
</div>
</div>

<!-- Pie Chart -->
<div class="col-xl-4 col-lg-5">
<div class="card shadow mb-4">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary">Monetizado</h6>
</div>
<div class="card-body">
<p>Monetizado is an on-chain pay-per-view platform that allows you to monetize any web page and static content (if you don't have access to the backend to make changes) through Web3.</p>
</div>
</div>
</div>
</div>

<!-- Content Row -->
<div class="row">

<div class="col-lg-6 mb-4">


</div>
</div>

</div>
<!-- /.container-fluid -->

</div>
<!-- End of Main Content -->

<!-- Footer -->
<footer class="sticky-footer bg-white">

</footer>
<!-- End of Footer -->

</div>
<!-- End of Content Wrapper -->

</div>
<!-- End of Page Wrapper -->

<!-- Scroll to Top Button-->
<a class="scroll-to-top rounded" href="#page-top">
<i class="fas fa-angle-up"></i>
</a>



<!-- Bootstrap core JavaScript-->
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

<!-- Core plugin JavaScript-->
<script src="vendor/jquery-easing/jquery.easing.min.js"></script>

<!-- Custom scripts for all pages-->
<script src="js/sb-admin-2.min.js"></script>



<script src="js/jquery.qrcode.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>
<script src="https://cdn.ethers.io/lib/ethers-5.2.umd.min.js" type="application/javascript"></script>
<script type="text/javascript" src="./js/monetizado.js"></script>

<script type="text/javascript">


var web3 = new Web3(new Web3.providers.HttpProvider("https://a.sentry.testnet.kiivalidator.com:8645"));

async function changeNetwork() {
if (window.ethereum.networkVersion !== 123454321) {
try {
await window.ethereum.request({
method: 'wallet_switchEthereumChain',
params: [{ chainId: web3.utils.toHex(123454321) }]
});
} catch (err) {
// This error code indicates that the chain has not been added to MetaMask
if (err.code === 4902) {
await window.ethereum.request({
method: 'wallet_addEthereumChain',
params: [
{
chainName: "Kiichain Testnet",
chainId: web3.utils.toHex(123454321),
nativeCurrency: { name: "kii", decimals: 18, symbol: "kii" },
rpcUrls: ["https://a.sentry.testnet.kiivalidator.com:8645"]
}
]
});
}
}
}
}

async function checkIfUserHasAccess() {
await changeNetwork();
var access = await window.monetizado.userHasAccess(web3);
var info = await window.monetizado.getContentInfo(web3);
if(access || (info != null && info.isProtected == false)) {
document.getElementById("protected-content").style.display = "none";
document.getElementById("exclusive-content").style.display = "block";
document.getElementById("payBtn").style.display = "none";
} else {
await verifyContentInfo();
document.getElementById("protected-content").style.display = "block";
document.getElementById("exclusive-content").style.display = "none";
document.getElementById("payBtn").style.display = "block";
}
}

async function verifyContentInfo() {
await changeNetwork();
var info = await window.monetizado.getContentInfo(web3);
if(info != null) {
document.getElementById("amountToPay").textContent = web3.utils.fromWei(info.accessCost.toBigInt(),"ether");

}
}

async function verifyContentByCreator() {
await changeNetwork();
var info = await window.monetizado.getContentList(web3);
return info;
}

async function payForAccess() {
await changeNetwork();
var amount = document.getElementById("amountToPay").textContent;
amount = web3.utils.toWei(amount,"ether");
var txId = await window.monetizado.payContent(web3,amount);
return txId;
}
checkIfUserHasAccess();

$(function() {
var monetizadoLink = $('link[rel="monetizado"]');
var hrefValue = monetizadoLink.attr('href');
$('#monetizadopointer').text(hrefValue);
})

</script>
</body>

</html>
1 change: 1 addition & 0 deletions js/monetizado.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const networks = {
"etherlink:testnet" : "0x4dA05ddA2F0586327E956548fd3E88a508ba2168",
"filecoin:testnet" : "0x6388418CfEa921C323b91B173E10D7f8f1193680",
"fuse:testnet" : "0x4dA05ddA2F0586327E956548fd3E88a508ba2168",
"kii:testnet" : "0x4dA05ddA2F0586327E956548fd3E88a508ba2168",
"linea:testnet" : "0x4dA05ddA2F0586327E956548fd3E88a508ba2168",
"lisk:testnet" : "0x4dA05ddA2F0586327E956548fd3E88a508ba2168",
"meter:testnet" : "0x923720cA17B2e071542FE7419394EA717fdC1b98",
Expand Down

0 comments on commit 25739ea

Please sign in to comment.