Usando o aioha no js vanilla:
Download o bundle.js em
https://unpkg.com/@aioha/aioha@latest/dist/bundle.js
No seu projeto:
import { initAioha, Aioha, Providers, KeyTypes, constructTxHeader,broadcastTx } from "./bundle.js"; //local
const aioha = initAioha()
// Get registered providers
console.log(aioha.getProviders())
if (aioha.isLoggedIn()) {
console.log(aioha.getCurrentUser(), aioha.getCurrentProvider())
}
Agora você pode fazer login:
aioha.login(Providers.Keychain, "sm-silva", { msg: "Hello World", keyType: KeyTypes.Posting } ); // string, { msg: string, keyType: KeyTypes, loginTitle?: string }
loginAndDecryptMemo(username, options) // string, { msg: string, keyType: KeyTypes }
.logout() // sem argumentos
.encryptMemo("#mensagem", KeyTypes.Memo, "UserDoAlvo") // string, KeyTypes, string
.encryptMemoWithKeys("#mesagem", KeyTypes.Memo, ["STM6VBwfDVUJXKiUe3E89McM2MnBjcGJERwRdKbmUkcfzpHSDakgm"]) // string, KeyTypes, array
decryptMemo(memo, keyType) // string(#memo), KeyTypes.Memo
.claimRewards()
.signMessage('message', KeyTypes.Posting) // string, KeyTypes
.signTx(tx, KeyTypes.Active) // constructTxHeader([Op()]), KeyTypes Isso é para pegar só a assinatura
signAndBroadcastTx(tx, keyType) // object(hive tx), KeyTypes
.vote('author', 'permlink', 10000) // string, string, int(0–10000)
.comment( null, 'tagprincipal', "my-permlink", "my-title", "mybody", "{}") // string, string, string, string, string, object, object?
.comment( 'authorparent', 'tagprincipal', "my-permlink", "my-title", "mybody", "{}") // comentario
.customJSON( KeyTypes.Posting ,"follow",{ follower: "meu-usuario", following: "fulano", what: ["blog"] }, "Follow someone") // KeyTypes, string id, string|object, string
.transfer('recipient', 1, 'HIVE', 'Transferred using Aioha with memo') // string, number(3 decimals), string, string(memo)
recurrentTransfer(to, amount, memo, recurrence, executions, currency?) // string, number, string, int, int, string
.stakeHive(1, aioha.getCurrentUser()) // number(3 decimals), string?MyAccount,PowerUp
.unstakeHive(1) // number(3 decimals) PowerDown
.delegateStakedHive("delegateeAccount", 1) // string, number(3 decimals)Amount
delegateVests(delegatee, vests) // string, number(6 decimals)
.voteWitness('gtg', true) // AccountNameString, true or false
voteProposals(proposals, approve) // number[] | string[], boolean
.setProxy('gtg') // string Account Name
addAccountAuthority(account, keyType, weight) // string, KeyTypes, int
removeAccountAuthority(account, keyType) // string, KeyTypes
addKeyAuthority(publicKey, keyType, weight) // string, KeyTypes, int
removeKeyAuthority(publicKey, keyType) // string, KeyTypes
vscTransfer(to, amount, token, memo) // string, string|number, string, string
vscWithdraw(to, amount, token, memo) // string, string|number, string, string
vscStake(stakeType, amount, receiver, token, extra?) // VscStakeType, number, string, string, any?
vscUnstake(stakeType, amount, receiver, token, extra?) // VscStakeType, number, string, string, any?
Como fazer login(keychain):
aioha.login(Providers.Keychain, "sm-silva", { msg: "Hello World", keyType: KeyTypes.Posting, loginTitle: "MyAppName", } );Como restaurar o login:
const aioha = initAioha(); if (aioha.isLoggedIn()) { console.log("Usuário restaurado:", hive.getCurrentUser()); //ver o usuario } aioha.getCurrentProvider(); // para saber por onde esta conectado aioha.getProviders(); //para ver todos lugares que esta conectado [array]Fazer logout:
aioha.logout(); aioha.deregisterProvider(hive.getCurrentProvider()); // talvez?