testing cross chain post

avatar

testing crosschain posting



0
0
0.000
7 comments
avatar
(Edited)

Pseudo copy and paste. Be aware that the steem/hive chain doesn't like some characters common to coding-also some characters could have been lost converting it to a somewhat hive chain friendly format.

Checkout the time stamp of https://palnet.io/testing/@firstamendment/testing-crosschain-post with this time stamp of the original post here.

<?php

//insert refresh codes.
$code="refresh_code1";
$code2="refresh_code2";

//insert your secret that you stored at steemconnect, if any.
$secret="";
$secret2="";

//does https request to access and parse page with new access token.

$ch = curl_init("https://api.steemconnect.com/api/oauth2/token");
curl_setopt($ch,CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,"code=".$code."&client_secret=$secret");
$result="";
if (($result=curl_exec($ch)) === false) {}
$accesstoken=substr($result,strpos($result,":")+2,strpos($result,".")-16);

$ch = curl_init("https://hivesigner.com/api/oauth2/token");
curl_setopt($ch,CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,"code=".$code2."&client_secret=$secret2");
$result="";
if (($result=curl_exec($ch)) === false) {}
$accesstoken2=substr($result,strpos($result,":")+2,strpos($result,".")-16);

//if new post leave blank, else if comment original author
$name="";
//Your user name
$user="firstamendment";
//if a new post leave a single tag, else use author's permlink.
$path="testing";
//unique identifier; your permlink. if comment, may want to make $path.time().
$path2="testing-crosschain-post";
//title of post
$title="testing cross chain post";
//tags. if none leave as "\\\"\\\"". else "\\\"tag1\\\",\\\"tag2\\\",\\\"tag2\\\"..."
$cat="\\\"palnet\\\",\\\"stem\\\",\\\"coding\\\",\\\"steem\\\",\\\"hive\\\",\\\"bot\\\"";

//strangely new line characters need not a "\n" but a "\\n", per reason of json.
$data="testing crosschain posting";
$json = "{\"operations\": [[\"comment\",{\"parent_author\":\"".$name."\",\"parent_permlink\":";
$json.="\"".$path."\", \"author\" : \"".$user."\", \"permlink\" : \"".$path2;
$json.="\",\"title\" : \"".$title."\", \"body\":";
$json.="\"".$data."\", \"json_metadata\":\"{\\\"tags\\\":[".$cat."]}\"}]";
$json.=",[\"comment_options\", {\"author\": \"".$user."\", \"permlink\":\"".$path2."\", \"title\":\"".$title."\",\"max_accepted_payout\": \"1000000.000 SBD\", \"percent_steem_dollars\": 0, \"allow_votes\": true,\"allow_curation_rewards\": true, \"extensions\": []}]]}";
echo "\n<br>".$json;

$ch = curl_init("https://api.steemconnect.com/api/broadcast");
curl_setopt($ch,CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json );
curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json, text/plain, */*','authorization: '.$accesstoken,'content-type: application/json','DNT:1','Origin: http://127.0.0.1:8080/php.steem.php','','Sec-Fetch-Mode: cors','User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36'));
if (($result=curl_exec($ch)) === false) {}
echo "\n<br>r1:".$result;

$ch = curl_init("https://hivesigner.com/api/broadcast");
curl_setopt($ch,CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json );
curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json, text/plain, */*','authorization: '.$accesstoken2,'content-type: application/json','DNT:1','Origin: http://127.0.0.1:8080/php.steem.php','','Sec-Fetch-Mode: cors','User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36'));
if (($result=curl_exec($ch)) === false) {}
echo "\n<br>r2:".$result;
?>

0
0
0.000
avatar

Although one risks missing blocks: One could read the head block of one chain, have the script look for a post by you i the head block, parse out the data, reassemble the data, and automatically put it in the other chain. But really I just wanted to demonstrate that you can post on both chains at [about] once.

0
0
0.000
avatar
(Edited)

As hive was drawing closer, I was looking at the API nodes for whaleshares and weku to do mltiple cross chain postings. They both have api nodes, but the servers I found listed weren't up.
However, just knowing the main api isn't enough at my understanding of steem development. Something like steemconnect needs to be there too.

Although weku/whaleshares I think are pretty centralized, posting across all the forks adds an additional level of decentralization. Let's just say there were a million forks of steem, if you post to all 1 million of them it would be unlikely that it could be censored on all of them.

But that gets us to the issue of decentralization. Do people favor decentralization only when things are bad, but still strive for a good tzar to rescue them. Even if there are a million steem forks, people will tend to want to flock to certain leaders else they will just be alone in the middle of no where. Infinite choices tend to lead to volitional decisions, but in our mortal reality few things, ignoring molecules, atoms, and subatomic particles, are infinite or seemingly so. well it's late, but being a social creature seems to doom us.

0
0
0.000
avatar
(Edited)

It looks like on steemd.com and hiveblocks.com I've voted for this post twice (once for each chain).

0
0
0.000
avatar

Thanks for the upvotes. Did you manually upvote them, or did you write a script to upvote them in both locations?

https://steemd.com/tx/605b6ff743771a09122fa786622009f234c6e0a7
https://hiveblocks.com/tx/4c80a2d066c4305b63306aefa414118a46015524

0
0
0.000
avatar

Manually upvoted. I am still a beginner at programming and I am slowly teaching myself to code. Don't want to be a script kiddie forever. :-)

0
0
0.000
avatar

Even more thanks. Yesterday there were reports of dapps going all over the place on the two chains due to the swap. Even steemconnect was posting to hive for quite a while, until that was fixed.

Coding on steem/hive isn't too bad. Biggest hurdle is getting steemconnect/hivesigner set up right, then after that getting the jsons to work. Overall the lack of stellar dapps is likely due a lack of documentation, and devs trying to limit its use to social media stuff.

0
0
0.000