What does the 'signatory' keyword means in daml representation? - daml

In a DAML contract, what does the signatory keyword do? For example, in the Iou contract, what does the line signatory issuer, owner actually mean?
Does it mean both owner and issuer should be same?

One of the compelling features of DAML as a modeling language is that it is designed to help solve problems involving authorization and delegation. To achieve this DAML has a first class type Party that represents independent ledger participants, and every contract on the ledger must be authorized by one or more parties before it can be created.
The signatory expression in a template defines who must authorize the creation of a contract instance of this template. It does so in terms of the data contained within the proposed contract instance — this means that any party who can see a transaction that attempts to create a contract also has enough data to verify the creation was properly authorized.
In the case of the Iou contract:
template Iou
with
issuer : Party
owner : Party
currency : Text
amount : Decimal
observers : [Party]
where
signatory issuer, owner
...
A party wishing to create an Iou must fill in the record: issuer, owner, currency, etc. Then they must pass that record to the create function within a transaction submitted to the ledger. That call to create must be authorized by issuer and owner, but does not require authorization by observers as they are not listed as a signatory.
Note that it is legal for issuer and owner to be the same party. In fact, this would be the only way for the create to be legally submitted directly to the ledger as individual ledger interactions can only be authorized by a single party. Larger authorization sets must occur as a part of a larger transaction using delegated authority from other contracts already on the ledger.
For more on this, and especially on how to do authority delegation, see the DAML documentation: https://docs.daml.com/concepts/ledger-model/ledger-structure.html
For a worked example, see: https://docs.daml.com/daml/patterns/initaccept.html and the other examples in the Patterns section of the DAML docs.

Related

How to check if an NTF is sold from another contract not managed by me?

Scenario
My Smart contract (SM-A) can be used only if you own a specific NFT created and managed by another contract (SM-B).
If so, it stores additional information inside a mapping property :
msg.sender address
account name
and other properties to cover the SM-A business requirements.
Constraints
I'm the owner of SM-A.
I'm NOT the owner of SM-B and I don't have chance to change anything about it.
Questions
Is there a way for having information if and when the msg.sender sells his NFT from SM-B in order to remove his data from my mapping property stored in SM-A?
If so, how it works the cost of the delete transaction operation?
Will my contract pay for it?

Can an ethereum smart contract address hold many types of tokens?

I know that an ethereum funds address can hold many types of tokens. If the address is a contract address, can it also hold many types of tokens? or it can only hold the token it defines?
In other words, is it true that any address in ethereum can:
have at most one smart contract attached to it. This allows other users to locate this smart contract.
have arbitrary types of tokens attached to it. The address here allows other smart contract to keep track of the balance this address owns.
^ Is this correct? Thanks.
Both your assumptions are correct.
I'll just clear out the fact that it's not the "owner" address holding the tokens per se. The information which address owns how many tokens (or which tokens, in case of NFTs) is stored on each token contract. Also, blockchain explorers (such as EtherScan or BscScan) aggregate this data in their off-chain databases, so it's easier to search on their site.
Example:
Contract 0x123 (token ABC) holds the information that Address A owns 1 ABC token.
Contract 0x456 (token DEF) holds the information that Address A owns 2 DEF tokens.
A blockchain explorer has all this info aggregated in their off-chain DB, so that users can simply filter "all tokens by Address A" and they don't have to keep querying all token contracts asking "How many of your tokens does Address A own?".

How to check if token has transaction charge(i.e token is deflationary)

Before making a transaction via web3 i wanted to check if token is deflationary. Do we have any common method for erc20 token contracts to check whether they are deflationary or not. I checked the abi for several defalationary tokens but thay don't seem to have any common method amongst them
There is no standard that would define a general way to recognize a deflationary token.
The logic can be processed in many ways:
Part of the transfer() and transferFrom() functions
A separate burn() function
executable by an authorized address
executable by each token owner allowing them to burn their own tokens
can use any name - burnFrom(), removeTokens(), lowerSupply(), ...

ERC-721: How to determine which Tokens an Address Own

If you are using the ERC-721 standard, what is the prefer method determining which tokens the address owns in a DAPP.
Currently I'm request all the Transfer Events for an address and basically sorting them into transfer in and transfer out, and then using that to determine which tokens the user owns.
Is there a simpler way I missed.
Transfer events may be emitted also by contracts that are not ERC-721 tokens, or some noname tokens that you might not be interested in.
The actual token ownership is stored in the tokens contracts (and not the DAPP contract).
So your current approach is pretty much as straightforward as it can get, if you want to automatically keep track of all tokens that the address currently owns (and some false positives as well).
Note: This is also similar to the approach of Etherscan, which listens to all Transfer event logs and if the sender contract is listed in their database of tokens, they use the event log data to update balances of the sender and recipient.
If you're willing/able to create and maintain a list of tokens that you want to follow, I'd recommend a simpler approach:
Define the list of followed token contract addresses (e.g. ECF or RARI)
For each of these token contracts, call balanceOf(<your_dapp_address>) that returns amount of tokens that the <your_dapp_address> currently owns.

How to get lists of ERC20, ERC721 and ERC827 tokens from Ethereum address

How can I get lists of ERC20, ERC721 and ERC827 tokens in a particular Ethereum wallet address? Also I would like to be able to get the name, symbol, logo, and balance from the main net.
ERC-721 includes an optional interface (optional means the contract implementor can choose if they want to implement it) to enumerate tokens owned by a specific account.
Su Squares implements this feature, but few other contracts do it.
You can use tools like Etherscan, Enjinx Blockchain Explorer or write your own interface to a Ethereum JSON RPC host to collect the data.
I don't think you can do a total data dive per address. I think you have to go the other way around, meaning looking if a contract contains a certain token. For the major tokens like EOS, this should be easy with MEW.
But if you're looking for some obscure tokens such as the ones below, you probably have to add them to MEW manually to check:
Crap Coin (CRP)
Ingrid Is a Horrible Human Coin (iHH)
Banana Coin