Hello, Everyone.
I hope everything is fine.This is my first post to the Steem Dev Community. It's also my first post as a moderator in this community. This community is only for Steem blockchain development-based idea sharing, tutorials, projects, or any type of development-related topic.
Today I am sharing a tutorial about how to create a simple multi-wallet STEEM/SBD transfer script using the steem-js library.Lets Start. It's very easy and simple. We don't use enough CSS code to make it mobile-responsive and gorgeous. We only focus on the script here. Lets Start..
First When we create an HTML page in Notepad or any other code editor, we write the basic HTML structure like below:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Multi Wallet Transfer tool.</title>
</head>
<body>
<script>
</script>
</body>
</html>
Then we use the steem-js cdn source link in the head tag:
<script src="https://cdn.jsdelivr.net/npm/steem/dist/steem.min.js"></script>
Then we create a form like below in the body tag.:
<form>
<label><b>From Username:</b> label><input type="text" autocomplete="username" style="width:200px;" placeholder="Without @ ex: moh.arif" id="from_username"><br><br>
<label><b>Private Active Key:</b> label><input type="password" autocomplete="current-password" style="width:385px;" placeholder="active key" id="wif"><br><br>
<textarea placeholder="Example : rme 0.1 steem/sbd memo." rows="6" cols="70" id="box"></textarea><br><br>
<input type="button" value="Transfer" onclick="transfer()"><br><br><br>
<textarea readonly placeholder="Successful transaction lines will be shown here..." rows="6" cols="70" id="rcv"></textarea><br><br>
</form>
Then we write script code that includes a function called "transfer," which is called when the Transfer button is pressed. If you analyze the full code, I think you understand all these things clearly.
The complete code is as follows:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Multi Wallet Transfer tool.</title>
<script src="https://cdn.jsdelivr.net/npm/steem/dist/steem.min.js"></script>
</head>
<body>
<center>
<b>Total Transfer Given :</b> b><br>
<b>Total successful Transfer: </b> b><br>
<b>Total Failed Transfer: </b> b><br><br>
<form>
<label><b>From Username:</b> label><input type="text" autocomplete="username" style="width:200px;" placeholder="Without @ ex: moh.arif" id="from_username"><br><br>
<label><b>Private Active Key:</b> label><input type="password" autocomplete="current-password" style="width:385px;" placeholder="active key" id="wif"><br><br>
<textarea placeholder="Example : rme 0.1 steem/sbd memo." rows="6" cols="70" id="box"></textarea><br><br>
<input type="button" value="Transfer" onclick="transfer()"><br><br><br>
<textarea readonly placeholder="Successful transaction lines will be shown here..." rows="6" cols="70" id="rcv"></textarea><br><br>
</form>
</center>
<script>
function transfer(){
var from= document.getElementById("from_username").value.toLowerCase();
var key= document.getElementById("wif").value;
var text= document.getElementById("box").value;
var memo="";
var s_lines= "successful Transfer Lines: \n";
var i;
var st=0;
var ust=0;
setTimeout(function() {
var array1= text.split("\n");
for( i=0;i<array1.length;i++){
var array2=array1[i].split(" ");
var to= array2[0].toLowerCase();
var asset_ammount = Number(array2[1]).toFixed(3);
var asset= array2[2].toUpperCase();
var amount =asset_ammount+" "+asset;
for(var j=3;j<array2.length;j++){
memo+= array2[j]+" ";}
steem.broadcast.transfer(key, from, to, amount, memo, function(err, result) {
if (!err){
s_lines+= (result.operations[0][1].to+" "+result.operations[0][1].amount+" "+result.operations[0][1].memo+"\n");
console.log(result.operations[0][1].to+" "+result.operations[0][1].amount+" "+result.operations[0][1].memo);
st+=1;}
if (err){
console.log(err);
ust+=1;}
document.getElementById("transfer-count").value = i;
document.getElementById("sucessful-transfer").value = st;
document.getElementById("unsucessful-transfer").value = ust;
document.getElementById("rcv").value = s_lines;
});
memo="";
}}, 3000 * i);
}
</script>
</body>
</html>
You can use multi wallet steem/sbd transfer from here: https://amarbanglablog.w3spaces.com/transfer.html Thanks everyone for reading this tutorial. Bye.