Solidity. Основы. Блокчейн
586 subscribers
15 photos
8 videos
28 links
Solidity.
Основы.
Блокчейн
Download Telegram
Вопрос для ETH разработчика.

В чем разница между private, internal, public, and external functions?

Возможный вариант ответа:

Модификаторы видимости обязательны, всего их бывает 4. Указывает на то, откуда функция может быть вызвана:

external - внешние функции, могут быть вызваны только из другого контракта или через транзакцию, вызов func() не сработает внутри контракта, сработает this.func(), но практика с использованием this нежелательна, поскольку такая операция дороже. Если у вас появилась потребность вызвать external функцию внутри контракта, то лучше переименуйте её в public(следующий пункт)

public - функции с этим модификатором могут быть вызваны откуда угодно

internal - внутренние функции, нельзя вызвать через транзакцию, можно вызвать внутри контракта и контрактов, наследующих его. В этом случае this не работает

private - функции с этим модификатором можно вызвать только внутри текущего контракта


#вопрос #eth #собеседование
👍4
Вопрос для ETH разработчика.

What is the difference between create and create2?

What is CREATE
Smart contracts can be created both by other contracts and regular EOA.They both compute the new address the same way:

new_address = keccak256(sender, nonce)


So each created address is associated with a nonce value.Nonce increased on every transaction.It is related to the number of transactions we make and is unpredictable. That’s why we need CREATE2.

What is CREATE2?
The whole idea behind this opcode is to make the resulting address independent of future events. Regardless of what may happen on the blockchain, it will always be possible to deploy the contract at the precomputed address.There are four parameters in CREATE2 function:
* 0xFF
* the address of sender
* A salt (random value from sender)
* bytecode (the code of the new contract)

new_address = keccak256(0xFF, sender, salt, bytecode)


Обьяснение на русском читайте по ССЫЛКЕ

#вопрос #eth #собеседование
🔥3👍1
Вопрос для ETH разработчика.

Насколько большим может быть смарт-контракт?

Ответ:
The Solidity max contract size is 24,576 bytes. This contract code size limit was introduced in EIP-170 with the Spurious Dragon hard-fork. The purpose of this limit is to prevent denial-of-service (DOS) attacks.

Максимальный размер контракта Solidity составляет 24 576 байт. Это ограничение размера кода контракта было введено в
EIP-170 с хард-форком Spurious Dragon. Целью этого ограничения является предотвращение DOS aтак.

#вопрос #eth #собеседование
What prevents infinite loops from running forever?
Почему нет бесконечных циклов в Solidity?

The transaction gas limit prevents infinite loops from running forever.
Так как есть лимит газа.

#вопрос #eth #собеседование
🔥6👍1
Вопрос для SOLIDITY разработчика.

What major change with arithmetic happened with Solidity 0.8.0?


Starting with version 0.8.0, Solidity automatically includes checks for arithmetic underflows and overflows as a built-in feature of the language. Before version 0.8.0, integer underflows and overflows were allowed and would not cause an error. Since version 0.8.0, Solidity will revert if an expression causes an integer underflow or overflow.

На русском можно почитать по ссылке

#вопрос #eth #собеседование
Вопрос для solidity разработчика.

What special CALL is required for proxies to work?


DELEGATECALL is required for proxy contracts to work because this type of call will preserve the msg (msg.sender, msg.value, etc…) and run in the context of the calling contract instead of the called contract. This enables the proxy contract to call an implementation contract to modify the proxy contract’s state.
By using DELEGATECALL, the implementation contract can be upgraded without the smart contract system losing any information or having to change the address of the proxy.


Больше про DELEGATECALL по ссылке

#вопрос #eth #собеседование
👌2
Вопрос для ETH разработчика.

What are the challenges of creating a random number on the blockchain?

Answer: Random number generation on the blockchain is difficult because of its deterministic and public nature. The Ethereum Virtual Machine (EVM) must produce the same output given the same input, and all data on the blockchain is public.

Как сгенерировать настоящие случайные числа в Solidity с блокчейном

#вопрос #eth #собеседование
👍2
Which is better to use for an address allowlist: a mapping or an array? Why?

Answer: A mapping is better for an address allowlist because it is more gas efficient. With a mapping, it is possible to check if an address is on the allowlist by directly accessing its value. Using an array, verifying an address could be costly because it would require looping through each element.

Mapping в Solidity

Расчет количества газа необходимого для выполнения транзакции в Ethereum

#вопрос #eth #собеседование
👍2
What is the difference between assert and require?

assert and require serve different purposes. The require function is commonly used for input validation or to validate the state before executing certain logic. The assert function is used to check for invariants, to ensure that there’s no error in the contract’s logic and to prevent conditions that should never be possible.

#вопрос #eth #собеседование
👍1
What is the minimum amount of Ether required to run a solo staking node?
Каково минимальное количество эфира, необходимое для запуска соло-стейкинга?

32 ETH
Solo staking: The most secure option, you'll need to 32
ETH to stake and have a dedicated computer with a reliable and constant connection.

Staking pools: You join a pool using any amount of
ETH, which is used to create a node of 32 ETH.

Статья на русском

#вопрос #eth #собеседование
2👍1🤝1
Mastering Ethereum

Автор:
Andreas M.
Год издания:
2019

#eth #en

Скачать книгу
2
Ethereum Smart Contract Development

Автор:
Mayukh Mukhopadhyay
Год издания:
2018

#eth #en

Скачать книгу
👍21