hive-keychain/hive-keychain-extension

query: how can I use this for backend(node js). I want to transfer tokens

aster2709 opened this issue · 10 comments

Hey awesome wallet. My use case is to transfer 'x' tokens from user in the backend. I'm able to use the package in frontend ofcourse doing requestSendToken. how can this be achieved in nodejs? I understand that I'd need the users keys but what are the calls.

thanks alot!

sn0n commented

https://developers.hive.io/apidefinitions/#broadcast_ops_transfer

https://developers.hive.io/tutorials-javascript/transfer_hive_and_hbd.html
Is a JavaScript tutorial, but it uses frontend as well as backend. But the actual broadcast is the first link.

Indeed, as @sn0n mentioned above, you should rather check hive dev documentation, since on the backend side you cannot use Keychain.
Actually, you don't necessarily need the user key to do this. An alternative way is to use the add_account_authority operation, in order to whitelist an account to be able to broadcast on behalf of user accounts.
That being said, transfers require active authority, and I doubt anyone would be willing to giving active authority to a third-party since it would enable to transfer out the account holdings.

sn0n commented

Another sidenote on that note,..

I think the way most services working with transfers on hive are streaming blocks on the backend looking for transfers to go through, and handling the actual transfer off to the customers choice of app.

hey guys, I just said user on a whim. but its going to be me and my key only. I'm wanting to transfer tokens in backend. the transfer operation says you can only transfer HIVE or HBD? but I am needing to transfer hive engine tokens like SPS, etc etc

sn0n commented

hey guys, I just said user on a whim. but its going to be me and my key only. I'm wanting to transfer tokens in backend. the transfer operation says you can only transfer HIVE or HBD? but I am needing to transfer tokens like SPS, etc etc

That would be using hive engine, their website ( https://hive-engine.com/?p=faq ) references: https://github.com/harpagon210/sscjs

Edit: the above may be wrong, my apologies. To transfer hive-engine tokens, it's a custom json broadcast.

https://hive-engine.github.io/engine-docs/

&&

https://developers.hive.io/apidefinitions/#broadcast_ops_custom_json

Will have more info on that.

thanks sir. i looked into the hive-engine sscjs package. the docs aren't clear on how to do that. but thanks for the leads, I'll take it there as it my issue doesn't deal with hive-keychain 👍

hey @sn0n @stoodkev the hive-engine doesn't have much for dev support. keychain also does hive engine token transfers, so how do u guys do it? please show me so I can read into it thanks!

sn0n commented

Their discord is probably the best bet: https://discord.gg/xWRYB9s

Alot of it depends on what you are building, as far as an actual broadcast, hivejs and the links above should get you there. What specifically do you want to accomplish?

You need to broadcast a json with this format :

const id = "ssc-mainnet-hive";
const json = {
    contractName: "tokens",
    contractAction: "transfer",
    contractPayload: {
      symbol: token,
      to: account_to,
      quantity: amount,
      memo: memo,
    },
  };

thanks sirs!