create account

But is it useful. Custom Json on the chain. by penderis

View this thread on: hive.blogpeakd.comecency.com
· @penderis ·
$1.36
But is it useful. Custom Json on the chain.
<div class="text-justify"> 

I was playing with <a href="https://webmakerapp.com">Web Maker App</a> as an alternative to codepen , and have been meaning to actually do something with the chain. 

I remember I have this obsession with custom_json and how useful it can be but wanted to do it in vanilla js. I also completely over-engineered what I would do etc.  

Today I just did not. I just hacked together some pieces and went for it. This is the horrifying tale of that.

<br><hr>
<center><img src="https://steemitimages.com/p/6VvuHGsoU2QBt9MXeXNdDuyd4Bmd63j7zJymDTWgdcJjo1YLnsw35v16X3zH6qovKA3C6CTLj7mXJtG1nuAhjfpbi4oSe66jCfCDoG4EbnfMExcXM5U36rvhdLg5Gi"></center>
<br><hr>
Imagine the most simple, horrible html form you can then beat it with a brick. The html I added was just to have a semblance to a DOM instead of hardcoding everything. Which I did anyway with the message I sent, F the man. 

<br>

<pre><code>//HTML
&lt;form&gt;
  &lt;input id="account" type="text" placeholder="account name" name="account"&gt;
  &lt;input id="key" type="password" placeholder="posting Key" name="key"&gt;
   &lt;button id="doshit"&gt;Do Shit&lt;/button&gt;
   &lt;button id="domoreshit"&gt;Send that shit&lt;/button&gt;
&lt;/form&gt;
</code></pre>

<br>

Since <a href="https://webmakerapp.com">Web Maker App</a> links the libraries for us there is no need for a local file and script hassles. It is simple enough to actually take the data and put it in the required structure even by just getting the info from a direct call to the api without using any libraries. I sooooooo wanted to try it vanilla, these libraries are hard. 

Then I looked at the authentication helpers to broadcast the transaction to the chain and pissed myself a little. 

In the app you may proceed and link the <a href="https://github.com/jnordberg/dsteem">Dsteem library</a> , use a version below 0.11.0 else shit is just fucked up. So that is from version ^0.8.0 - ^0.10.0

Now, this is not pretty, I promise you it is not a tutorial or anything. It is just something that had to be done. 

<br>

<pre><code>//JAVASCRIPT
//set up steem client. 
const client = new dsteem.Client('https://api.steemit.com');
<br>
//stuff to send in transaction
//use account name as unique prefix and because I like my name ok. 
let transactionBody = {
  id: "penderis_sos",
  json: "",
  required_auths: [],
  required_posting_auths: []
}
//When is the party, is clothing optional? This is the data we care about
let jsonBody = {
  call: "penderis",
  why: "for a good time",
  when: "horny"
}
//it is a funny word no idea wtf it means I actually hate it 
//just say private key you prick
let wif
<br>
let doshit = document.getElementById('doshit');
//make it if we clicky it then it speaky to the thingy
doshit.addEventListener('click', function(event){
  event.preventDefault();
  //trigger get the shitty info and doing stuff via the event listener 
  //because I am not going to build out form inputs fuck that shit. 
  //ok maybe I will. fuckit
  let accountName = document.getElementById('account').value;
  let accountKey = document.getElementById('key').value;
  //dsteem will take your text and make it special or you get a useless error
  wif = dsteem.PrivateKey.from(accountKey);
  <br>
  //probably should not use push, but tell me when will I ever in 
  //my fucking in life require multiple names to sign this shit. 
  //But probably should not use push or it will be wrong
  transactionBody.required_posting_auths.push(accountName);
  transactionBody.json = JSON.stringify(jsonBody);
    //shall we see if this updates the variables. 
  console.log(transactionBody);
})
<br>
let domoreshit = document.getElementById("domoreshit");
//make it so when we clicky it then it listens to the speaky and tattles
domoreshit.addEventListener('click',function(event){
  event.preventDefault();
  <br>
  //Sign, seal and hopefully deliver everything we heard.
  client.broadcast.json(transactionBody,wif).then(
    function(result){
      console.log(result);
    },
    function(error){
    console.log(error);
    }
  )
})  
</code></pre>

<br><hr>
<center><img src="https://steemitimages.com/p/gPCasciUWmEwHnsXKML7xF4NE4zxEVyvENsPKp9LmDaFuyySbc17LP9pnrVXFtesJFRxbBC8o7xCFK9ttQeHkAVz8bLmAx5UkX2n4cQmAftmEB5mB5xr3BDjZJXjpHTVA4fzEE4UaoRb38Q3iE"></center>
<br><hr>
Now I looked before posting but I don't actually think I can just go and index these things without streaming blocks or some shit. Which begs the question. Ok not a question just a random thought. Nah, this typing thing is getting boring and I think I just realized that the only use for the chain is to monetize. I do feel better posting a few words also though, not a complete gold digger. I will whisper sweet nothings also. 

</div>
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 235 others
properties (23)
authorpenderis
permlinkbut-is-it-useful-custom-json-on-the-chain
categorycode
json_metadata{"tags":["code","learning","writing","steem","likejesusbutbetter"],"image":["https://steemitimages.com/p/6VvuHGsoU2QBt9MXeXNdDuyd4Bmd63j7zJymDTWgdcJjo1YLnsw35v16X3zH6qovKA3C6CTLj7mXJtG1nuAhjfpbi4oSe66jCfCDoG4EbnfMExcXM5U36rvhdLg5Gi","https://steemitimages.com/p/gPCasciUWmEwHnsXKML7xF4NE4zxEVyvENsPKp9LmDaFuyySbc17LP9pnrVXFtesJFRxbBC8o7xCFK9ttQeHkAVz8bLmAx5UkX2n4cQmAftmEB5mB5xr3BDjZJXjpHTVA4fzEE4UaoRb38Q3iE"],"links":["https://webmakerapp.com","https://github.com/jnordberg/dsteem"],"app":"steemit/0.1","format":"markdown"}
created2019-01-02 22:13:15
last_update2019-01-02 22:13:15
depth0
children2
last_payout2019-01-09 22:13:15
cashout_time1969-12-31 23:59:59
total_payout_value1.080 HBD
curator_payout_value0.277 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length4,759
author_reputation153,480,448,063,664
root_title"But is it useful. Custom Json on the chain."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id77,777,287
net_rshares2,585,236,511,566
author_curate_reward""
vote details (299)
@free-reign ·
I like that you've put comments in your code.  Way to go!
properties (22)
authorfree-reign
permlinkre-penderis-but-is-it-useful-custom-json-on-the-chain-20190103t121501971z
categorycode
json_metadata{"tags":["code"],"app":"steemit/0.1"}
created2019-01-03 12:15:21
last_update2019-01-03 12:15:21
depth1
children0
last_payout2019-01-10 12:15:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length57
author_reputation45,562,832,914,797
root_title"But is it useful. Custom Json on the chain."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id77,806,393
net_rshares0
@utopiaeducators ·
So funny
👍  
👎  
properties (23)
authorutopiaeducators
permlinkqfip9k
categorycode
json_metadata{"app":"hiveblog/0.1"}
created2020-08-23 12:56:09
last_update2020-08-23 12:56:09
depth1
children0
last_payout2020-08-30 12:56:09
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length8
author_reputation-4,088,797,786,952
root_title"But is it useful. Custom Json on the chain."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,227,699
net_rshares0
author_curate_reward""
vote details (2)