Skip to content

walletContent Internal Action

Nilson Lazarin edited this page Sep 12, 2024 · 1 revision
Internal Actions Wiki

.velluscinum.walletContent

(available at velluscinum >= 24.7.23)

Retrieves the content of a Wallet and return a belief with a list of assets, like: b(List).

DESCRIPTION

.velluscinum.walletContent(S,P,Q,l);
Parameters Description
l It's a belief that represents the content (list) of a wallet.
P It's a literal that represents the agent's private key.
Q It's a literal that represents the agent's public key.
S It's a literal that represents the address of a DLT node.

EXAMPLE

/* Initial beliefs and rules */
chainServer("http://testchain.chon.group:9984/").
aliceWallet("AFL794vuN2D4uWzdJsnbLtMRSz1b9bvmYxKy8RoFntKB").

/* Initial goals */
!start.

/* Plans */
+!start <-
    ?chainServer(S);
	.velluscinum.buildWallet(myWallet);
	.wait(myWallet(P,Q));
	.velluscinum.deployToken(S,P,Q,"criptocurrency:myCoin",1000,myCoin);
	.wait(myCoin(CoinID));
	?aliceWallet(Alice);
	.velluscinum.transferToken(S,P,Q,CoinID,Alice,50);
    	
	.velluscinum.walletContent(S,P,Q,wallet);
    .wait(wallet(Content));

	!findToken(CoinID,set(Content));/* Searching a specific Digital Asset, by ID */
//	!findToken(nft,set(Content));   /* Searching all Non-Fungible Tokens in the Digital Wallet */
//	!findToken(token,set(Content)); /* Searching all Fungible Tokens in the Digital Wallet */
.

+!findToken(Term,set([Head|Tail])) <- 
	!compare(Term,Head,set(Tail));
	!findToken(Term,set(Tail)).

+!compare(Term,[Type,AssetID, Qtd],set(V)): (Term  == Type) | (Term == AssetID) <- 
	.print("Type: ", Type, " ID: ", AssetID," Qtd: ", Qtd)
 	/* TODO */
.

-!compare(Term,[Type,AssetID,Qtd]    ,set(V)) 
//	<- .print("The Asset ",AssetID, " is not a ",Term)
.

-!findToken(Type,set([   ])) 
//	<- .print("End of List.")
.