Может кто-нибудь показать, как спарсить количество этериума с https://etherscan.io отправленного с одного адреса на другой? Т.е допустим у меня есть текстовое поле, человек вводит туда свой адрес и ему выдается сколько он отправил в сумме за все время на другой адрес.
Update: дописал свой скрипт, но когда хочу проверить сколько средств было отправлено на адрес, то получаю ошибку: Error: contract not deployed (contractAddress="", operation="getDeployed", version=4.0.4)
Вот скрипт:
$(document).ready(function () {
let abi = [ { "anonymous": false, "inputs": [ { "indexed": true, "name": "previousOwner", "type": "address" }, { "indexed": true, "name": "newOwner", "type": "address" } ], "name": "OwnershipTransferred", "type": "event" }, { "constant": false, "inputs": [], "name": "addMigrateBalance", "outputs": [], "payable": true, "stateMutability": "payable", "type": "function" }, { "constant": false, "inputs": [ { "name": "numIterations", "type": "uint256" } ], "name": "distribute", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "anonymous": false, "inputs": [ { "indexed": false, "name": "investorAddress", "type": "address" }, { "indexed": false, "name": "value", "type": "uint256" } ], "name": "OnDepositeReceived", "type": "event" }, { "constant": false, "inputs": [], "name": "finishMigration", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "anonymous": false, "inputs": [ { "indexed": false, "name": "investorAddress", "type": "address" }, { "indexed": false, "name": "value", "type": "uint256" } ], "name": "OnPaymentSent", "type": "event" }, { "constant": false, "inputs": [ { "name": "_oldContract", "type": "address" }, { "name": "_from", "type": "uint256" }, { "name": "_to", "type": "uint256" } ], "name": "migrateDeposite", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [], "name": "renounceOwnership", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "newDistributorAddress", "type": "address" } ], "name": "setDistributorAddress", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "newMaxDeposite", "type": "uint256" } ], "name": "setNewMaxDeposite", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "newMinDeposite", "type": "uint256" } ], "name": "setNewMinDeposite", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "newWallet1", "type": "address" }, { "name": "newWallet2", "type": "address" }, { "name": "newWallet3", "type": "address" } ], "name": "setNewWallets", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "newPromoWallet", "type": "address" } ], "name": "setPromoWallet", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "newOwner", "type": "address" } ], "name": "transferOwnership", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "payable": true, "stateMutability": "payable", "type": "fallback" }, { "inputs": [], "payable": false, "stateMutability": "nonpayable", "type": "constructor" }, { "constant": true, "inputs": [], "name": "amountForDistribution", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "amountRaised", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "currentPaymentIndex", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "", "type": "uint256" } ], "name": "deposites", "outputs": [ { "name": "depositor", "type": "address" }, { "name": "amount", "type": "uint256" }, { "name": "depositeTime", "type": "uint256" }, { "name": "paimentTime", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "", "type": "address" }, { "name": "", "type": "uint256" } ], "name": "depositors", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "depositorsCount", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "getAllDepositesCount", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "getAllDepositorsCount", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "getAmountRaised", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "_id", "type": "uint256" } ], "name": "getDeposit", "outputs": [ { "name": "", "type": "address" }, { "name": "", "type": "uint256" }, { "name": "", "type": "uint256" }, { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "depositor", "type": "address" } ], "name": "getDepositesCount", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "depositor", "type": "address" }, { "name": "depositeNumber", "type": "uint256" } ], "name": "getDepositeTime", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "getLastDepositId", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "lastIndex", "type": "uint256" } ], "name": "getLastPayments", "outputs": [ { "name": "", "type": "address" }, { "name": "", "type": "uint256" }, { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "depositor", "type": "address" }, { "name": "depositeNumber", "type": "uint256" } ], "name": "getPaimentStatus", "outputs": [ { "name": "", "type": "bool" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "depositor", "type": "address" }, { "name": "depositeNumber", "type": "uint256" } ], "name": "getPaimentTime", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "depositor", "type": "address" }, { "name": "depositeNumber", "type": "uint256" } ], "name": "getUserDeposit", "outputs": [ { "name": "", "type": "uint256" }, { "name": "", "type": "uint256" }, { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "addr", "type": "address" } ], "name": "isContract", "outputs": [ { "name": "", "type": "bool" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "isOwner", "outputs": [ { "name": "", "type": "bool" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "maxDeposite", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "migrationFinished", "outputs": [ { "name": "", "type": "bool" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "minDeposite", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "owner", "outputs": [ { "name": "", "type": "address" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "percent", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" } ];
let address = '';
// - string; e.g. 'homestead', 'ropsten', 'rinkeby', 'kovan'
//let network = ethers.providers.networks.rinkeby;
let provider = ethers.getDefaultProvider('homestead');
let contract = new ethers.Contract(address, abi, provider);
contract.getAmountRaised().then(function(value) {
let AmountRaised = ethers.utils.formatEther(value) * 1;
$('#AmountRaised').html(AmountRaised.toFixed(2));
$.getJSON( "https://api.coinmarketcap.com/v2/ticker/1027/", function( data ) {
val = AmountRaised * data['data']['quotes']['USD']['price'];
$('#USD').html(val.toFixed(2))
});
});
contract.getAllDepositesCount().then(function(value) {
//console.log(value.toString());
$('#AllDepositesCount').html(value.toString());
});
async function getLastPayments(count) {
count = count > 10 ? 9 : count - 1;
for (let i = count; i >= 0; i--) {
let dep = await contract.getLastPayments(i)
let addr = dep[0].substr(0,5)+"..."+dep[0].substr(35,7)
let ethval = ethers.utils.formatEther(dep[2].toString())
let time = dep[1].toString();
let date = new Date(time*1000);
let day = date.getDate();
let month = date.getMonth() + 1;
let y = date.getFullYear();
let formattedTime = day + '/' + month + '/' + y;
let row = i%2 ? "even_row" : "odd_row";
// let status = dep[3].toString();
// status = status == 0 ? "Не завершено" : "Завершено";
status = "Завершено";
$("#LastDeposit").append("<div class='"+row+"'><div class='tbl_header_col1'><div>"+addr+"</div></div><div class='tbl_header_col2'><div>"+formattedTime+"</div></div><div class='tbl_header_col3'><div class='table_data_amount'>"+ethval+"</div></div><div class='tbl_header_col4'><div class='txt_final'>"+status+"</div></div></div>");
}
}
contract.currentPaymentIndex().then(function(value) {
let count = value.toString();
//console.log(count);
getLastPayments(count);
});
async function getDepositesCount(count) {
let user = $("#wallet").val();
for (let i = 0; i < count; i++) {
let dep = await contract.getUserDeposit(user, i)
let addr = user.substr(0,5)+"..."+user.substr(35,7)
let ethval = ethers.utils.formatEther(dep[0].toString())
let time = dep[1].toString();
let date = new Date(time*1000);
let day = date.getDate();
let month = date.getMonth() + 1;
let y = date.getFullYear();
let formattedTime = day + '/' + month + '/' + y;
let row = i%2 ? "even_row" : "odd_row";
let status = dep[2].toString();
if (status > 0) {
ethval = parseFloat(ethval) + parseFloat(ethval * 0.2);
ethval = ethval.toFixed(3)
}
status = status == 0 ? "<span style='color:#333'>Не завершено</span>" : "Завершено";
$("#userDeps").append("<div class='userDep "+row+"'><div class='tbl_header_col1'><div>"+addr+"</div></div><div class='tbl_header_col2'><div>"+formattedTime+"</div></div><div class='tbl_header_col3'><div class='table_data_amount'>"+ethval+"</div></div><div class='tbl_header_col4'><div class='txt_final'>"+status+"</div></div></div>");
}
}
$("#dep-form").submit(function(e){
e.preventDefault();
let user = $("#wallet").val();
$(".userDep").detach();
contract.getDepositesCount(user).then(function(value) {
let count = value.toString();
console.log(count);
if (count > 0) {
getDepositesCount(count)
} else {
$("#userDeps").append("Не учавствует")
}
});
});
provider.getBalance(address).then(function(value) {
let AmountRaised = ethers.utils.formatEther(value.toString());
//console.log(AmountRaised);
let left = 20 - AmountRaised;
$('#ethLeft').html(left.toFixed(2));
$.getJSON( "https://api.coinmarketcap.com/v2/ticker/1027/", function( data ) {
val = left * data['data']['quotes']['USD']['price'];
$('#usdLeft').html(val.toFixed(2))
});
})
});
$("#copy-button").click(function (event) {
event.preventDefault();
CopyToClipboard($("#post-shortlink").html(), false, "");
});
function CopyToClipboard(value, showNotification, notificationText) {
var $temp = $("<input>");
$("body").append($temp);
$temp.val(value).select();
document.execCommand("copy");
$temp.remove();
if (typeof showNotification === 'undefined') {
showNotification = true;
}
if (typeof notificationText === 'undefined') {
notificationText = "Copied to clipboard";
}
var notificationTag = $("div.copy-notification");
if (showNotification && notificationTag.length == 0) {
$('#copypopover').popover('show');
setTimeout(function () {
$('#copypopover').popover('hide');
}, 1500);
}
}
Есть у кого идеи?
Айфон мало держит заряд, разбираемся с проблемой вместе с AppLab
Перевод документов на английский язык: Важность и ключевые аспекты
Какие существуют виды рекламных бордов и как выбрать подходящий?
Ребят всем приветУ меня есть инпут, который добавляет изоображение
В картах OSM я новичок, саму карту получилось сгенерировать на javascript, но нужно добавить маркеры к населенным пунктам на карту, читала, что это...
Объявленные в js сотрудники должны появляться в HTML все один за одним, а отображается только последний
С помощью стрелок на клавиатуре нужно перемещать фокус по ряду селектовЧтобы избежать смены options при перемещении по селектам применяется...