Hot answers tagged

77

With msg.sender the owner can be a contract. With tx.origin the owner can never be a contract. In a simple call chain A->B->C->D, inside D msg.sender will be C, and tx.origin will be A. msg.sender is preferred for the flexibility it provides. Furthermore, for Serenity, even though it's a while out, Vitalik recommends avoiding tx.origin: How do I make my ...


18

msg.sender gives the direct sender of the message, so for example a contract that passed it along. tx.origin gives the origin of the transactions, so the user address it was originally sent from. In practice this will always be a user so eth's answer holds true.


18

I'm glad you asked because this was the main thing we are testing in Status - the viability of Whisper. There's many factors that come into play here. Firstly, let me describe how Whisper roughly works, how Status tries to compensate and what might be happening here. Whisper is an identity based encrypted messaging protocol that has dark routing, to learn ...


15

You can sign a string of data using web3.eth.sign The address you use needs to be unlocked and you can sign text like this: > web3.eth.sign(<your address>, web3.sha3("Some text")) 0x32f689696d855dd79c73acd94b2374461261b6f3d00e758fa23d35607c0be3175cbc7a7ea02c7f23cd7ef9334b4718a3363dfe12c1c1de24da5f94eb68a67b6000" The returned 130byte ...


10

You can now verify signatures in web3 1.0 using web3.eth.accounts.recover const account = web3.eth.accounts[0]; const signature = await web3.eth.sign("Hello world", account); const signingAddress = web3.eth.accounts.recover("Hello world", signature); // account === signingAddress


8

You are checking if 1000000000000000000 divided by 2 has a remainder of 0 which it has. If you want to check if only whole ethers are send you need to check if amount modulo 1000000000000000000 does not equal 0. So your code would be: uint amount; amount = msg.value; if (amount % 1 ether != 0 ) { msg.sender.send(amount); return; }


7

At this point it's difficult to give a very accurate answer to your questions as Whisper is still very much in its infancy stage, however I'll attempt to answer your question with the implemenation that's currently in operation. The amount of whisper topics that you may use for your messages and filters are theoretical infinite. Please note that whisper ...


7

To keep the core protocol of Ethereum simple and generic, the protocol has the rule that a message always executes the code of an account. Simple and generic allows the critical consensus protocol to be smaller and decrease the risk of consensus bugs. This means that a detail, such as the Ethereum Contract ABI, does not need to be defined in the core ...


5

Notice that web3js will always prefix the string with "\x19Ethereum Signed Message:\n" before signing it. If you want to create a signature without this prefix, you could use eth-crypto.


4

The comment above saying "Yes, token-transfer always has a value of 0" is wrong. The correct answer to the question is that--no--there is nothing that precludes a token transfer and an ether transfer from happening in the same transaction. It is true to say that most ERC20 token smart contracts are coded to disallow it, but that is in no way the same thing ...


3

Whisper First of all, Whisper is kind of a database to spread announcements to the Ethereum network - or more precisely, to all geth nodes who have enabled Whisper. By default, Whisper is hidden behind a flag. Whisper can be used to send messages. Sending messages will have the following properties: Receiver anonymity: no one knows who the actual receiver ...


3

No. Signing is just a mathematical operation, which can be done on- or offline, and which happens to the transaction before it's broadcast to the network. It's not something that happens in the EVM, so doesn't require gas. Messages are usually signed by clients, but all they're doing is calling a function is some library to do some maths. So this is ...


3

Code is run as a response to a transaction. This always happens when there is code in the account. msg.data being empty doesn't mean no code should be called, there is no such "rule", it only means there is no input.


3

I'm assuming you would like to send a message along with a transaction that goes to a "normal" account, not a "smart contract" account. Maybe even from a "normal" account as well. What you can do is convert your text message to hex, using any online converter, for example this one. Most wallets have a data field for a transaction, where you then paste the ...


2

This is not possible in general. Internal calls to other contracts are only part of single transaction execution. However, if a called contract emits logs they are available in transaction receipts.


2

Here's a simple example with the users maintaining their own information. For simplicity, I've got the users first registering with a function made for that purpose, and then updating (if needed) with functions made for that purpose. pragma solidity ^0.4.6; contract UserRegistry { struct UserStruct { string name; string url; ...


2

Yes, everything in the blockchain is public and can be read by anyone. See the "Nothing is Hidden" section of https://programtheblockchain.com/posts/2018/01/02/making-smart-contracts-with-public-variables/. There is no way for a smart contract to keep a secret, so the only secrets that can exist on the blockchain are ones that are encrypted and decrypted ...


2

The value of the data field is definitely stored. Otherwise it would be impossible for nodes to replay/validate old transactions.


2

The accepted answer is slightly incorrect. EC library would sometimes (around 1 in 100 in my randomized testing) return ->r or ->s parameters shorter than 64 characters. Which is different from the JS implementation. So you have to left-zero-pad them: $r = str_pad($signature->r->toString(16), 64, '0', STR_PAD_LEFT); $s = str_pad($...


2

t and v are aliases for type and value, as mentioned in the docs you linked: an object with {type: 'uint', value: '123456'} or {t: 'bytes', v: '0xfff456'} The type is used for ABI encoding the value, before hashing it.


1

Welcome to SE! There is no method to "request" a payment from someone, mostly because the change would be done in that contract, and there is no way of "notifying" the involved party, especially if Y is a normal account address. The current flows for ERC20 are: approval by X, then transferFrom(X) by Y transfer to Y by X For ERC-677: When X is a ...


1

There is no node in the network started as bootnode. But I have manually added static nodes using admin.addPeer(). There are three main nodes, their enode is shared publicly where any new coming peers connected to all those three using admin.addPeer("mX_enode"). mX stands for either m1 or m2 or m3. Also all those 3 nodes are connected to each other using ...


1

Yes, usually the token contract will reject a transfer with a non zero value. For a contract method to receive ethers it should be marked as payable, but the transfer method does not have such modifier. Moreover most token contracts will reject any transfer made after the crowdsale is over.


1

As a rule of thumb, everything costs gas inside the system. A contract calling another contract costs gas. All smart contract executions within Ethereum are initiated by some end-user account. This account is the one who pays for all the used gas. So even if you send a transaction to just one contract, the contract may send internal transactions to other ...


1

Does this mean that if you send a message / transaction to an address that doesnt exist, it the call would succeed? Yes. How does the key management work? I'm not sure I understand the question. For Ethereum accounts, a private key is randomly generated, a public key is derived from that, and then an address is derived from that. If you have the private ...


1

Sending a transaction to a random address is equiavalent to 'burning' or 'destroying' the tokens. This is actually something that is already commonly done with the all '0' address, and 0x000000000000000000000000000000000000dEaD. Take a read here: Transaction recipient - Mastering Ethereum Ethereum does no further validation of this field. Any 20-byte ...


1

My answer is based on the current version of the yellow paper. I_w Iw, the permission to make modifications to the state The importance of this flag is explained in the paragraph about Exceptional Halting: Take into consideration only the last condition, it says that if the permission to modify is false and the current instruction is one specified by W ...


1

I found a solution. In the official documentation 'WEB3.PY -> SHH' everything is described well, except for the indication that the filter should be started in a parallel process. Those. it is necessary to send and receive the file into two files + run the file in an infinite loop with a certain frequency of listening on the filter. The code itself will tell ...


1

The true is that both statements are correct somehow. A contract can attach a message when making a transfer to an external owned account. But the message is not easily accessible for an external account to read it. pragma solidity ^0.4.19; contract A { // Make a transfer to who and attach message m function bar(address who, bytes m) public ...


1

You can sign whatever you want off-chain with your private key and deliver it to someone else however you want (e.g. HTTP or email). This is how "payment channels" work without incurring transaction fees.


Only top voted, non community-wiki answers of a minimum length are eligible