What do you withdraw there? It doesnβt look like there are parameters in the abi and also it doesnβt look like it is payable.
first function is send deposit amount (bnb) and referral address
the second function is just the function of outputting to the address of the sender of the request and the smart contract itself will pay the accrued interest
If the function doesnβt have parameters then you donβt have to send it parameters.
- function: 1- amount payable 2- uplline addres
- function: withdraw
async function deposit() {
const amount = document.getElementById('#Amount-Payable').value;
const address = document.getElementById('#Uplline-Address').value;
const ABI = [
{
"inputs": [
{
"internalType": "address",
"name": "_upline",
"type": "address"
}
],
"name": "deposit",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
];
const sendOptions = {
contractAddress: "0xEc08f00FE90fcf5e205b45Ac067f22C6F0e0854B",
functionName: "deposit",
abi: ABI,
params: {
_upline: "#Uplline_Address",
},
msgValue: "#Amount_Payble"
};
await Moralis.executeFunction(sendOptions);
}
And this one doesnβt work?
Still trying to figure out if Iβm on the right track?))
async function Withdraw() {
const ABI = [
{
"inputs": [],
"name": "withdraw",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
];
const sendOptions = {
contractAddress: "0xEc08f00FE90fcf5e205b45Ac067f22C6F0e0854B",
functionName: "withdraw",
abi: ABI,
};
await Moralis.executeFunction(sendOptions);
}
document.getElementById('#withdraw').onclick = Withdraw;
It seems fine to me, I think that you are on the right track.
I made logic from this video
https://www.youtube.com/watch?v=jdx2H1alijQ&t=2739s 37.min.
maybe itβs outdated?
did with another video
https://www.youtube.com/watch?v=7TKqLJd_aYI 2 min.
I canβt figure out what I did wrong?
- the shutdown button does not work for me
- the form is not written and does not go into a smart contract
- and the exit button does not work
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
<meta name="generator" content="Hugo 0.88.1">
<title>SMART CONTRACT</title>
<link rel="canonical" href="https://getbootstrap.com/docs/5.1/examples/headers/">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="headerss.css">
<link rel="stylesheet" href="style.css">
<script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>
<script src="https://unpkg.com/moralis/dist/moralis.js"></script>
</head>
<body>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-patch-check-fill"
viewBox="0 0 16 16">
<symbol id="bi-patch-check-fill" viewBox="0 0 18 18">
<title>Smart Contract</title>
<path fill-rule="evenodd" clip-rule="evenodd" fill="dodgerblue"
d="M10.067.87a2.89 2.89 0 0 0-4.134 0l-.622.638-.89-.011a2.89 2.89 0 0 0-2.924 2.924l.01.89-.636.622a2.89 2.89 0 0 0 0 4.134l.637.622-.011.89a2.89 2.89 0 0 0 2.924 2.924l.89-.01.622.636a2.89 2.89 0 0 0 4.134 0l.622-.637.89.011a2.89 2.89 0 0 0 2.924-2.924l-.01-.89.636-.622a2.89 2.89 0 0 0 0-4.134l-.637-.622.011-.89a2.89 2.89 0 0 0-2.924-2.924l-.89.01-.622-.636zm.287 5.984-3 3a.5.5 0 0 1-.708 0l-1.5-1.5a.5.5 0 1 1 .708-.708L7 8.793l2.646-2.647a.5.5 0 0 1 .708.708z" />
</path>
</symbol>
</svg>
<main>
<h1 class="visually-hidden">Headers</h1>
<div class="container">
<header class="d-flex flex-wrap justify-content-center py-3 mb-4 border-bottom">
<ul class="nav nav-pills">
<li onclick="login()" id="btn-login" class="nav-item"><a href="#" class="nav-link active" aria-current="page">Join to Wallet</a>
<script>
const serverUrl = "https://1jjca2c1r4ab.usemoralis.com:2053/server";
const appId = "f21REKbxRDZtrz0D7O7zcVqx7GjVy7cbbYHOdxd8";
Moralis.start({ serverUrl, appId });
async function login() {
const user = await Moralis.authenticate()
document.getElementById('btn-login').innerHTML = user.get('ethAddress')
}
</script>
</li>
<li onclick="logout()" id="btn-logout" class="nav-item"><a href="#" class="nav-link" aria-current="page">Disconnect</a>
<script>
async function logout() {
const user = await Moralis.User.logOut();
document.getElementById('btn-logout')
}
</script>
</li>
</ul>
</header>
</div>
</main>
</body>
</html>
<main class="col-md-9 ms-sm-4 col-lg-10 px-md-4">
</div>
<p>
<h2>Deposit</h2>
<div class="table-responsive">
</p>
<p>
<div class="form-floating">
<input type="amount" class="form-control" id="Amount-Payable" placeholder="Amount-Payable">
<label for="Amount-Payable">
<spann>*</spann>BNB Amount Payable (Min 0.1 BNB)
</label>
</div>
</p>
<p>
<div class="form-floating">
<input type="address" class="form-control" id="Uplline-Address" placeholder="Uplline-Address">
<label for="Uplline-Address">
<spann>*</spann>Uplline Address Ref Partners (0x0123456789...AbΡ)
</label>
</div>
</p>
<button onclick="deposit()" id="deposit" class="w-100 btn btn-lg btn-primary" type="submit">Send BNB and create a deposit</button>
</div>
<p>
<h2>Withdraw</h2>
<div class="table-responsive">
</div>
</p>
<button onclick="withdraw()" id="withdraw" class="w-100 btn btn-lg btn-primary" type="submit">Withdraw interest in BNB</button>
</div>
</main>
<script src="main.js"></script>
</body>
</html>
console.log('Hello world');
// connect to Moralis server
const serverUrl = "https://1jjca2c1r4ab.usemoralis.com:2053/server";
const appId = "f21REKbxRDZtrz0D7O7zcVqx7GjVy7cbbYHOdxd8";
Moralis.start({ serverUrl, appId });
// ΠΠΏΠΎΠΏΠΊΠ° ΠΠΎΠ΄ΠΊΠ»ΡΡΠ΅Π½ΠΈΡ ΠΌΠ΅ΡΠ°ΠΌΠ°ΡΠΊ https://docs.moralis.io/moralis-dapp/users/web3-login/metamask
login = async () => {
await Moralis.authenticate().then(async function (user) {
console.log('logged in');
window.location.href = "indexx.html";
})
}
// Π€ΡΠ½ΠΊΡΠΈΡ ΠΎΡΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΡ Π°Π΄ΡΠ΅ΡΠ° ΠΊΠΎΡΠ΅Π»ΡΠΊΠ° Ρ ΡΠ·Π΅ΡΠ° ΠΏΠΎΡΠ»Π΅ ΠΏΠΎΠ΄ΠΊΠ»ΡΡΠ΅Π½ΠΈΡ
async function login() {
const user = await Moralis.authenticate()
document.getElementById('login').innerhtml = user.get('ethAddress')
}
if (document.querySelector('#btn-login') != null) {
document.querySelector('#btn-login').onclick = login;
}
// ΠΠ½ΠΎΠΏΠΊΠ° ΠΡΠΊΠ»ΡΡΠ΅Π½ΠΈΡ ΠΌΠ΅ΡΠ°ΠΌΠ°ΡΠΊ (Π½Π°Π΄ΠΎ ΠΏΡΠΎΠ²Π΅ΡΠΈΡΡ Π½Π΅ ΡΡΠ°Π±Π°ΡΡΠ²Π°Π΅Ρ)
logout = async () => {
await Moralis.User.logout();
window.location.href = "indexx.html";
}
async function logout() {
await Moralis.User.logout();
window.location.href = "indexx.html";
}
if (document.querySelector('#btn-logout') != null) {
document.querySelector('#btn-logout').onclick = logout;
}
// Π€ΠΎΡΠΌΠ° ΠΎΡΠΏΡΠ°Π²ΠΊΠΈ Π΄Π°Π½Π½ΡΡ
Π² ΡΠΌΠ°ΡΡ ΠΊΠΎΠ½ΡΡΠ°ΠΊΡ ΡΠΎΡΠΌΠ° Π΄Π΅ΠΏΠΎΠ·ΠΈΡ (Π½Π°Π΄ΠΎ ΠΏΡΠΎΠ²Π΅ΡΠΈΡΡ) https://docs.moralis.io/moralis-dapp/web3/web3#example-of-calling-a-write-contract-method
async function deposit() {
await Moralis.executeFunction(sendOptions)
amount.set("amount", document.getElementById('Amount-Payable').value);
address.set("address",document.getElementById('Uplline-Address').value);
const amount = document.getElementById('Amount-Payable').value;
const address = document.getElementById('Uplline-Address').value;
const ABI = [
{
"inputs": [
{
"internalType": "address",
"name": "_upline",
"type": "address"
}
],
"name": "deposit",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
];
const sendOptions = {
contractAddress: "0xEc08f00FE90fcf5e205b45Ac067f22C6F0e0854B",
functionName: "deposit",
abi: ABI,
params: {
_upline: "Uplline_Address",
},
msgValue: Motalis.units.Eth("Amount_Payble")
};
await Moralis.executeFunction(sendOptions);
}
if (document.querySelector('#deposit') != null) {
document.getElementById('#deposit').onclick = deposit
}
// Π€ΠΎΡΠΌΠ° ΠΎΡΠΏΡΠ°Π²ΠΊΠΈ Π΄Π°Π½Π½ΡΡ
Π² ΡΠΌΠ°ΡΡ ΠΊΠΎΠ½ΡΡΠ°ΠΊΡ ΠΊΠ½ΠΎΠΏΠΊΠ° ΠΡΠ²ΠΎΠ΄ (Π½Π°Π΄ΠΎ ΠΏΡΠΎΠ²Π΅ΡΠΈΡΡ) https://docs.moralis.io/moralis-dapp/web3/web3#example-of-calling-a-write-contract-method
async function withdraw() {
await Moralis.executeFunction(sendOptions)
const ABI = [
{
"inputs": [],
"name": "withdraw",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
];
const sendOptions = {
contractAddress: "0xEc08f00FE90fcf5e205b45Ac067f22C6F0e0854B",
functionName: "withdraw",
abi: ABI,
};
await Moralis.executeFunction(sendOptions);
}
if (document.querySelector('#withdraw') != null) {
document.getElementById('#withdraw').onclick = withdraw;
}
const transaction = await Moralis.executeFunction(sendOptions);
console.log(transaction.hash);
// --> "0x39af55979f5b690fdce14eb23f91dfb0357cb1a27f387656e197636e597b5b7c"
// Wait until the transaction is confirmed
await transaction.wait();
// Read new value
const message = await Moralis.executeFunction(readOptions);
console.log(message);
// --> "Hello Moralis"
// ΠΈΡΡΠΎΡΠ½ΠΈΠΊΠΈ: https://forum.moralis.io/t/write-contract-web3-interact-web-site-moralis-executefunction-api-abi/15096
// ΡΠΌΠ°ΡΡ ΠΊΠΎΠ½ΡΡΠ°ΠΊΡ Π±ΡΠΊ https://testnet.bscscan.com/address/0xec08f00fe90fcf5e205b45ac067f22c6f0e0854b#code
// ΡΡΠ½ΠΊΡΠΈΡ Π½Π°ΠΏΠΈΡΠ°Π½ΠΈΡ Π²ΡΠ·ΠΎΠ²Π° https://docs.moralis.io/moralis-dapp/web3/web3#example-of-calling-a-write-contract-method
//
try to run the code directly in the browser console, for Moralis.executeFunction, with the values hardcoded for the parameters, then you can try to fix the html and the form
Yes, every time I look at the console, but I can not understand what is wrong
Uploading: Π‘Π½ΠΈΠΌΠΎΠΊ ΡΠΊΡΠ°Π½Π° 2022-05-22 Π² 15.25.31.pngβ¦what I wanted to say it to try to run directly in the browser console code like this, where you replace that line where msgValue is used with a constant value for msgValue
try to add some logging with console.log, it looks like there are some javascript syntax problems there, like that line with msgValue where Motalis.units.Eth("Amount_Payble")
has more than one problem and this is not going to execute
Yes, I understand, I followed the video instructions, but I need another function
i fixed some bugs and simplified the code
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
<meta name="generator" content="Hugo 0.88.1">
<title>SMART CONTRACT</title>
<script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>
<script src="https://unpkg.com/moralis/dist/moralis.js"></script>
</head>
<body>
<main>
<h1 class="visually-hidden">Headers</h1>
<div class="container">
<header class="d-flex flex-wrap justify-content-center py-3 mb-4 border-bottom">
<ul class="nav nav-pills">
<li onclick="login()" id="btn-login" class="nav-item"><a href="#" class="nav-link active"
aria-current="page">Join to Wallet</a>
<script>
const serverUrl = "https://1jjca2c1r4ab.usemoralis.com:2053/server";
const appId = "f21REKbxRDZtrz0D7O7zcVqx7GjVy7cbbYHOdxd8";
Moralis.start({ serverUrl, appId });
async function login() {
const user = await Moralis.authenticate()
document.getElementById('btn-login').innerHTML = user.get('ethAddress')
}
</script>
</li>
<li onclick="logout()" id="btn-logout" class="nav-item"><a href="#" class="nav-link"
aria-current="page">Disconnect</a>
<script>
async function logout() {
const user = await Moralis.User.logout(); // logOut ?
document.getElementById('btn-logout')
}
</script>
</li>
</ul>
</header>
</div>
</main>
</body>
</html>
<main class="col-md-9 ms-sm-4 col-lg-10 px-md-4">
</div>
<p>
<h2>Deposit</h2>
<div class="table-responsive">
</p>
<p>
<div class="form-floating">
<input type="amount" class="form-control" id="Amount-Payable" placeholder="Amount-Payable">
<label for="Amount-Payable">
<spann>*</spann>BNB Amount Payable (Min 0.1 BNB)
</label>
</div>
</p>
<p>
<div class="form-floating">
<input type="address" class="form-control" id="Uplline-Address" placeholder="Uplline-Address">
<label for="Uplline-Address">
<spann>*</spann>Uplline Address Ref Partners (0x0123456789...AbΡ)
</label>
</div>
</p>
<button onclick="deposit()" id="deposit" class="w-100 btn btn-lg btn-primary" type="submit">Send BNB and create a
deposit</button>
</div>
<p>
<h2>Withdraw</h2>
<div class="table-responsive">
</div>
</p>
<button onclick="withdraw()" id="withdraw" class="w-100 btn btn-lg btn-primary" type="submit">Withdraw interest in
BNB</button>
</div>
</main>
<script src="main.js"></script>
</body>
</html>
console.log('Hello world');
// connect to Moralis server
const serverUrl = "https://1jjca2c1r4ab.usemoralis.com:2053/server";
const appId = "f21REKbxRDZtrz0D7O7zcVqx7GjVy7cbbYHOdxd8";
Moralis.start({ serverUrl, appId });
// ΠΠΏΠΎΠΏΠΊΠ° ΠΠΎΠ΄ΠΊΠ»ΡΡΠ΅Π½ΠΈΡ ΠΌΠ΅ΡΠ°ΠΌΠ°ΡΠΊ https://docs.moralis.io/moralis-dapp/users/web3-login/metamask
login = async () => {
await Moralis.authenticate().then(async function (user) {
console.log('logged in');
window.location.href = "indexx.html";
})
}
// Π€ΡΠ½ΠΊΡΠΈΡ ΠΎΡΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΡ Π°Π΄ΡΠ΅ΡΠ° ΠΊΠΎΡΠ΅Π»ΡΠΊΠ° Ρ ΡΠ·Π΅ΡΠ° ΠΏΠΎΡΠ»Π΅ ΠΏΠΎΠ΄ΠΊΠ»ΡΡΠ΅Π½ΠΈΡ
async function login() {
const user = await Moralis.authenticate()
document.getElementById('login').innerhtml = user.get('ethAddress')
}
if (document.querySelector('#btn-login') != null) {
document.querySelector('#btn-login').onclick = login;
}
// ΠΠ½ΠΎΠΏΠΊΠ° ΠΡΠΊΠ»ΡΡΠ΅Π½ΠΈΡ ΠΌΠ΅ΡΠ°ΠΌΠ°ΡΠΊ (Π½Π°Π΄ΠΎ ΠΏΡΠΎΠ²Π΅ΡΠΈΡΡ Π½Π΅ ΡΡΠ°Π±Π°ΡΡΠ²Π°Π΅Ρ)
logout = async () => {
await Moralis.User.logout();
console.log('logout')
window.location.href = "indexx.html";
}
async function logout() {
await Moralis.User.logout();
console.log('logout')
window.location.href = "indexx.html";
}
if (document.querySelector('#btn-logout') != null) {
document.querySelector('#btn-logout').onclick = logout;
}
// Π€ΠΎΡΠΌΠ° ΠΎΡΠΏΡΠ°Π²ΠΊΠΈ Π΄Π°Π½Π½ΡΡ
Π² ΡΠΌΠ°ΡΡ ΠΊΠΎΠ½ΡΡΠ°ΠΊΡ ΡΠΎΡΠΌΠ° Π΄Π΅ΠΏΠΎΠ·ΠΈΡ (Π½Π°Π΄ΠΎ ΠΏΡΠΎΠ²Π΅ΡΠΈΡΡ) https://docs.moralis.io/moralis-dapp/web3/web3#example-of-calling-a-write-contract-method
async function deposit() {
await Moralis.executeFunction(sendOptions)
console.log('deposit')
amount.set("amount", document.getElementById('Amount-Payable').value);
address.set("address",document.getElementById('Uplline-Address').value);
const amount = document.getElementById('Amount-Payable').value;
const address = document.getElementById('Uplline-Address').value;
const ABI = [
{
"inputs": [
{
"internalType": "address",
"name": "_upline",
"type": "address"
}
],
"name": "deposit",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
];
const sendOptions = {
contractAddress: "0xEc08f00FE90fcf5e205b45Ac067f22C6F0e0854B",
functionName: "deposit",
abi: ABI,
params: {
_upline: "Uplline_Address",
},
msgValue: "Amount_Payble",
};
await Moralis.executeFunction(sendOptions);
console.log('deposit')
}
if (document.querySelector('#deposit') != null) {
document.getElementById('#deposit').onclick = deposit
}
// Π€ΠΎΡΠΌΠ° ΠΎΡΠΏΡΠ°Π²ΠΊΠΈ Π΄Π°Π½Π½ΡΡ
Π² ΡΠΌΠ°ΡΡ ΠΊΠΎΠ½ΡΡΠ°ΠΊΡ ΠΊΠ½ΠΎΠΏΠΊΠ° ΠΡΠ²ΠΎΠ΄ (Π½Π°Π΄ΠΎ ΠΏΡΠΎΠ²Π΅ΡΠΈΡΡ) https://docs.moralis.io/moralis-dapp/web3/web3#example-of-calling-a-write-contract-method
async function withdraw() {
await Moralis.executeFunction(sendOptions)
console.log('withdraw')
const ABI = [
{
"inputs": [],
"name": "withdraw",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
];
const sendOptions = {
contractAddress: "0xEc08f00FE90fcf5e205b45Ac067f22C6F0e0854B",
functionName: "withdraw",
abi: ABI,
};
await Moralis.executeFunction(sendOptions);
console.log('withdraw')
}
if (document.querySelector('#withdraw') != null) {
document.getElementById('#withdraw').onclick = withdraw;
}
you can not use strings as placeholders here, you have to use values for msgValue for example
I didnβt quite understand, that is, I wonβt be able to send the data of the completed form for writing to the smart contract?
Uploading: Π‘Π½ΠΈΠΌΠΎΠΊ ΡΠΊΡΠ°Π½Π° 2022-05-22 Π² 17.48.25.pngβ¦I mean, to test with real values, not with a string as placeholder.
msgValue: "Amount_Payble",
this is not going to work with a string for msgValue.
msgValue: Moralis.Units.ETH(β0.1β), instead of this value can i do this?
msgValue: Moralis.Units.ETH(βAmount_Payableβ),
You can try with that to see what happens.
try with a code like this:
await Moralis.enableWeb3();
ABI = [
{
"inputs": [
{
"internalType": "address",
"name": "_upline",
"type": "address"
}
],
"name": "deposit",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
];
sendOptions = {
contractAddress: "0xEc08f00FE90fcf5e205b45Ac067f22C6F0e0854B",
functionName: "deposit",
abi: ABI,
params: {
_upline: "0xEc08f00FE90fcf5e205b45Ac067f22C6F0e0854B",
},
msgValue: Moralis.Units.ETH("0.1")
};
await Moralis.executeFunction(sendOptions);
I Enable metamask and disable metamask.
but when i try to commit the transaction it fails. does not reach the metamask, what could be the reason?
HTML
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
<meta name="generator" content="Hugo 0.88.1">
<title>SMART CONTRACT</title>
<link rel="canonical" href="https://getbootstrap.com/docs/5.1/examples/headers/">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="headerss.css">
<link rel="stylesheet" href="style.css">
<script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>
<script src="https://unpkg.com/moralis/dist/moralis.js"></script>
</head>
<!-- TradingView Widget BEGIN -->
<div class="tradingview-widget-container">
<div class="tradingview-widget-container__widget"></div>
<script type="text/javascript" src="https://s3.tradingview.com/external-embedding/embed-widget-ticker-tape.js" async>
{
"symbols": [
{
"description": "BINANCE COIN",
"proName": "BINANCE:BNBUSDT"
},
{
"description": "BITCOIN",
"proName": "BINANCE:BTCUSDT"
},
{
"description": "ETHEREUM",
"proName": "BINANCE:ETHUSDT"
},
{
"description": "NEAR",
"proName": "BINANCE:NEARUSDT"
},
{
"description": "TETHER",
"proName": "BINANCEUS:USDTUSD"
},
{
"description": "MATIC",
"proName": "BINANCE:MATICUSDT"
},
{
"description": "AVALANCHE",
"proName": "BINANCE:AVAXUSDT"
},
{
"description": "CARDANO",
"proName": "BINANCE:ADAUSDT"
}
],
"showSymbolLogo": true,
"colorTheme": "light",
"isTransparent": true,
"displayMode": "adaptive",
"locale": "en"
}
</script>
</div>
<!-- TradingView Widget END -->
<body>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-patch-check-fill"
viewBox="0 0 16 16">
<symbol id="bi-patch-check-fill" viewBox="0 0 18 18">
<title>Smart Contract</title>
<path fill-rule="evenodd" clip-rule="evenodd" fill="dodgerblue"
d="M10.067.87a2.89 2.89 0 0 0-4.134 0l-.622.638-.89-.011a2.89 2.89 0 0 0-2.924 2.924l.01.89-.636.622a2.89 2.89 0 0 0 0 4.134l.637.622-.011.89a2.89 2.89 0 0 0 2.924 2.924l.89-.01.622.636a2.89 2.89 0 0 0 4.134 0l.622-.637.89.011a2.89 2.89 0 0 0 2.924-2.924l-.01-.89.636-.622a2.89 2.89 0 0 0 0-4.134l-.637-.622.011-.89a2.89 2.89 0 0 0-2.924-2.924l-.89.01-.622-.636zm.287 5.984-3 3a.5.5 0 0 1-.708 0l-1.5-1.5a.5.5 0 1 1 .708-.708L7 8.793l2.646-2.647a.5.5 0 0 1 .708.708z" />
</path>
</symbol>
</svg>
<main>
<h1 class="visually-hidden">Headers examples</h1>
<div class="container">
<header class="d-flex flex-wrap justify-content-center py-3 mb-4 border-bottom">
<a href="/" class="d-flex align-items-center mb-3 mb-md-0 me-md-auto text-dark text-decoration-none">
<svg class="bi me-2" width="40" height="32">
<use xlink:href="#bi-patch-check-fill" />
</svg>
<span class="fs-4">Smart Contract</span>
</a>
<ul class="nav nav-pills">
<li onclick="login()" id="btn-login" class="nav-item"><a href="#" class="nav-link active" aria-current="page">Join to Wallet</a></li>
<li class="nav-item"><a href="#" class="nav-link">Deposit</a></li>
<li class="nav-item"><a href="#" class="nav-link">Withdraw</a></li>
<li class="nav-item"><a href="#" class="nav-link">Info</a></li>
<li onclick="logout()" id="btn-logout" class="nav-item"><a href="#" class="nav-link">Disconnect</a></li>
</ul>
</header>
</div>
</main>
</body>
</html>
<main class="col-md-9 ms-sm-4 col-lg-10 px-md-4">
</div>
<p>
<h2>Deposit</h2>
<div id="tableOfDeposit" class="table-responsive">
<h1 class="h6 mb-6 fw-normal">Send BNB and get 0.6% every day!</h1>
</p>
<p>
<div class="form-floating">
<input type="text" class="form-control" id="Amount-Payable" placeholder="Amount-Payable">
<label for="Amount-Payable">
<spann>*</spann>BNB Amount Payable (Min 0.1 BNB)
</label>
</div>
</p>
<p>
<div class="form-floating">
<input type="Upline-Address" class="form-control" id="Uplline-Address" placeholder="Upline-Address">
<label for="Upline-Address">
<spann>*</spann>Uplline Adress Ref Partners (0x0123456789...AbΡ)
</label>
</div>
</p>
<button id="transfer-native" class="w-100 btn btn-lg btn-primary" type="button" onclick="transferNative()">Send BNB and create a deposit</button>
</div>
<p>
<h2>Withdraw</h2>
<div id="tableOfWithdraw" class="table-responsive">
<h1 class="h6 mb-6 fw-normal">Withdraw interest in BNB every 24 hours!</h1>
</div>
</p>
<button id="btn-withdraw" class="w-100 btn btn-lg btn-primary" type="button" onclick="withdraw()">Withdraw interest in BNB</button>
</div>
<p>
<h2>Info</h2>
<div id="tableOfInfo" class="table-responsive">
<h1 class="h6 mb-6 fw-normal">Withdraw interest in BNB every 24 hours!</h1>
</p>
</div>
<p>
<h2>Referral</h2>
<div id="tableOfReferral" class="table-responsive">
<h1 class="h6 mb-6 fw-normal">Withdraw interest in BNB every 24 hours!</h1>
</div>
</p>
<h2>Leaderboard</h2>
<div id="tableOfLeaderboard" class="table-responsive">
<h1 class="h6 mb-6 fw-normal">Withdraw interest in BNB every 24 hours!</h1>
</div>
<p>
<h2>Transactoins</h2>
<div id="tableOfTransaction" class="table-responsive">
<h1 class="h6 mb-6 fw-normal">Withdraw interest in BNB every 24 hours!</h1>
</div>
</p>
</div>
</main>
<script src="main.js"></script>
<script type="text/javascript" src="ERC20Abi.js"></script>
</body>
</html>
Main
`console.log("Hello world");
//connect to Moralis server
const serverUrl = "https://1jjca2c1r4ab.usemoralis.com:2053/server";
const appId = "f21REKbxRDZtrz0D7O7zcVqx7GjVy7cbbYHOdxd8";
Moralis.start({ serverUrl, appId });
// ΠΠΏΠΎΠΏΠΊΠ° ΠΠΎΠ΄ΠΊΠ»ΡΡΠ΅Π½ΠΈΡ ΠΌΠ΅ΡΠ°ΠΌΠ°ΡΠΊ https://docs.moralis.io/moralis-dapp/users/web3-login/metamask
login = async () => {
const user = await Moralis.authenticate();
document.getElementById("btn-login").innerHTML = user.get("ethAddress");
};
const loginButton = document.getElementById("btn-login");
const loginButtonHTML = loginButton.cloneNode(true);
loginButtonHTML.onclick = login;
// Π€ΡΠ½ΠΊΡΠΈΡ ΠΎΡΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΡ Π°Π΄ΡΠ΅ΡΠ° ΠΊΠΎΡΠ΅Π»ΡΠΊΠ° Ρ ΡΠ·Π΅ΡΠ° ΠΏΠΎΡΠ»Π΅ ΠΏΠΎΠ΄ΠΊΠ»ΡΡΠ΅Π½ΠΈΡ
// async function login() {
// const user = await Moralis.authenticate();
// document.getElementById("login").innerhtml = user.get("ethAddress");
// }
// if (document.querySelector("#btn-login") != null) {
// document.querySelector("#btn-login").onclick = login;
// }
// ΠΠ½ΠΎΠΏΠΊΠ° ΠΡΠΊΠ»ΡΡΠ΅Π½ΠΈΡ ΠΌΠ΅ΡΠ°ΠΌΠ°ΡΠΊ
logout = async () => {
const result = await Moralis.User.logOut();
if (result) {
document.getElementById("btn-login").innerHTML = "";
document.getElementById("btn-login").appendChild(loginButtonHTML);
}
};
// if (document.querySelector("#btn-logout") != null) {
// document.querySelector("#btn-logout").onclick = logout;
// }
// Π€ΠΎΡΠΌΠ° ΠΎΡΠΏΡΠ°Π²ΠΊΠΈ Π΄Π°Π½Π½ΡΡ
Π² ΡΠΌΠ°ΡΡ ΠΊΠΎΠ½ΡΡΠ°ΠΊΡ
async function transferNative() {
const amount = document.getElementById("Amount-Payable").value;
const address = document.getElementById("Uplline-Address").value;
// sending 0.1 tokens with 18 decimals to smart contract 0xEc08f00FE90fcf5e205b45Ac067f22C6F0e0854B
const options = {
type: "erc20",
amount: Moralis.Units.Token(amount, "18"),
receiver: "0x2075F1faf71eEEA9D2a649bFbbDDc79543d9fF9F",
contractAddress: "0xEc08f00FE90fcf5e205b45Ac067f22C6F0e0854B",
};
let result = await Moralis.transfer(options);
}
// document.getElementById("#transfer-native").onclick = logout;
async function withdraw() {
const sendOptions = {
contractAddress: "0xEc08f00FE90fcf5e205b45Ac067f22C6F0e0854B",
functionName: "withdraw",
abi: abi,
};
const transaction = await Moralis.executeFunction(sendOptions);
console.log(transaction.hash);
// --> "0x39af55979f5b690fdce14eb23f91dfb0357cb1a27f387656e197636e597b5b7c"
// Wait until the transaction is confirmed
await transaction.wait();
console.log("withdraw done");
}
`