Skip to content

transferToken Internal Action

Nilson Lazarin edited this page Sep 11, 2024 · 2 revisions
Internal Actions Wiki

.velluscinum.tranferToken

Transfer n units of a Token and returns a belief like; b(T);

DESCRIPTION

.velluscinum.transferToken(S,P,Q,C,R,V,b);
Parameters Description
b It's a belief that represents the result of an operation in DLT.
C It's a literal that represents a divisible asset;
P It's a literal that represents the agent's private key.
Q It's a literal that represents the agent's public key.
R It's a literal that represents the public key of a recipient agent.
S It's a literal that represents the address of a DLT node.
T It's a literal that represents a transaction performed in the DTL.
V It's a integer that represents the number of parts of a C.

EXAMPLE

  • Other agents

     /* Plans */
     +!whoWantsMoney[source(Agt)] <-
     	.velluscinum.buildWallet(myWallet);
     	.wait(myWallet(P,Q));
     	.send(Agt,achieve,sendMoney(Q));
     .
  • Agent Silvio Santos

     /* Initial beliefs and rules */
     bigChainDB("http://testchain.chon.group:9984/").
    
     /* Initial goals */
     !start.
    
     /* Plans */
     +!start <- 
     	.velluscinum.buildWallet(myWallet);
     	.wait(myWallet(P,Q));
     	?bigChainDB(S);
     	.velluscinum.deployToken(S,P,Q,"name:Silvio Coin",1000000,silvioCoin);
     	.broadcast(achieve,whoWantsMoney);
     .
    
     +!sendMoney(Wallet)[source(Agent)] <-
     	?silvioCoin(Token);
     	?myWallet(P,Q);
     	?bigChainDB(S);
     	.velluscinum.transferToken(S,P,Q,Token,Wallet,100,transferedTo(Agent));
     	.wait(transferedTo(Agent,TransactionID));
     	.print("Transfered 100 tokens to ",Agent," --> ",S,"api/v1/transactions/",TransactionID);
     .