Solidity Tutorial: Call function of other contract

  Рет қаралды 35,107

EatTheBlocks

EatTheBlocks

Күн бұрын

Пікірлер: 56
@Philson
@Philson 3 жыл бұрын
Dude, this tutorial was a life saver. Your easy demos are godlike~
@EatTheBlocks
@EatTheBlocks 3 жыл бұрын
Glad I could help!
@suyash-mehare
@suyash-mehare 2 жыл бұрын
yahh bro...... i go for 2-3 sites also tired 2 channels but i cant got the topic.. thanks to EatTheBlocks🙂
@manumonti_
@manumonti_ 4 жыл бұрын
Your Solidity videos are great! Thank you!
@EatTheBlocks
@EatTheBlocks 4 жыл бұрын
thanks Manuel :)
@magnetto90
@magnetto90 3 жыл бұрын
Thanks! I have been all weekend trying to do this.
@EatTheBlocks
@EatTheBlocks 3 жыл бұрын
Glad I could help!
@Mark-sx7uc
@Mark-sx7uc 3 жыл бұрын
so much content just in 10 minutes lol.. once I make more money as a solidity dev, I will buy your course like 3 times cause you deserve it! Thanks Julian!
@EatTheBlocks
@EatTheBlocks 3 жыл бұрын
Great to hear!
@smashergaming7711
@smashergaming7711 2 жыл бұрын
This is what I needed
@hardcorehistory8980
@hardcorehistory8980 2 жыл бұрын
You’re a mystic
@doctortasman
@doctortasman 3 жыл бұрын
Unreal - so direct and clear. TY
@EatTheBlocks
@EatTheBlocks 3 жыл бұрын
thanks!
@dungdang7920
@dungdang7920 2 жыл бұрын
Very good and funny videos bring a great sense of entertainment!
@kowsikgelli7257
@kowsikgelli7257 5 жыл бұрын
What is the use of interface when we can call the functions directly? Can you explain please. BY the way I am a big fan of your solidity series😊
@EatTheBlocks
@EatTheBlocks 5 жыл бұрын
awesome :) Interfaces allow you to easily communicate with another smart contract WITHOUT having to copy paste their whole code. This can be annoying if they have lots of different smart contract (ex: smart contract A import smart contract B which import smart contract C etc...now you have to copy paste all of them...)
@hamza-325
@hamza-325 3 жыл бұрын
Usually, the smart contracts that you call are not written by you but by some expert programmers around the world who write thousands of lines of code to make something great. So you shouldn't ask them to provide you with the original source files, but you should ask them for the signature only.
@NishantSingh-zx3cd
@NishantSingh-zx3cd 3 жыл бұрын
@@EatTheBlocks Thanks Man.
@dennisgonzales9521
@dennisgonzales9521 4 жыл бұрын
Thankyou julien
@MOTOACIDIC
@MOTOACIDIC 3 жыл бұрын
Is there something else that is needed for say contract A is a erc20 token and contract B is a betting contract to allow the holder of the erc20 to use their tokens from contract A to bet on contract B because after following this it always registers the address(this) and msg.sender as not holding any of contract A tokens when interacting with contract B.
@muhammedfayis003
@muhammedfayis003 4 жыл бұрын
Your videos are great, Here I have a doubt that you have not implemented/extended interfaceB on contract B, but then you cast the address as interfaceB and called functions of contract B on it. but here I wonder how the contract B relates with the interfaceB without any inheritation occured.
@dennisgonzales9521
@dennisgonzales9521 4 жыл бұрын
contract B is InterfaceB { // mark the function HelloWord() as override }
@m44235
@m44235 4 жыл бұрын
@@dennisgonzales9521 Awesome. I believe he missed that on his video. Otherwise I don't see it working.
@dennisgonzales9521
@dennisgonzales9521 4 жыл бұрын
@@m44235 Yeah. once you inherit the InterfaceB contract, it should work now.
@m44235
@m44235 4 жыл бұрын
@@dennisgonzales9521 Actually I just learned that you don't always need to extend the interface. Hard to explain it over a comment but check this out and see how interfaces are used w/o implementing the methods. github.com/compound-developers/compound-supply-examples
@VectorGameStudio
@VectorGameStudio 3 жыл бұрын
awesome tuts :)
@muhammadimtiazanwar
@muhammadimtiazanwar 2 жыл бұрын
Thank You 😊
@EatTheBlocks
@EatTheBlocks 2 жыл бұрын
You're welcome 😊
@MotherCoin
@MotherCoin 3 жыл бұрын
Life Saver Julien
@Lion-eh8pd
@Lion-eh8pd 4 жыл бұрын
Hi your videos are very nice. Can i send data or message to EOA from the smart contract by just knowing the address?
@EatTheBlocks
@EatTheBlocks 4 жыл бұрын
thanks :) No you cant send data to an EOA. An EOA has just an Ether balance, that's it. You can just send it some Ether.
@Lion-eh8pd
@Lion-eh8pd 4 жыл бұрын
Thanks for your reply
@kwkwbwjsj
@kwkwbwjsj 3 жыл бұрын
Hi i have some error when I make interfaceB contract It says that contract should be marked as abstruct How do i solve this?
@saberstoner
@saberstoner 3 жыл бұрын
how to call a function automatically ie. every 1hours, or at a certain time of day?
@Dufftata
@Dufftata 3 жыл бұрын
go to 5:18 Line 20: B b = B(addressB); It does compile in remix, but when I try to verify the code on ropsten.etherscan I get the error: DeclarationError: Identifier not found or not unique. 'B' is marked with the ^----^ expression
@Lion-eh8pd
@Lion-eh8pd 4 жыл бұрын
Is it necessary that the both the contracts must be in the same file? Can I call another contract function which is in another file without using the import keyword?
@EatTheBlocks
@EatTheBlocks 4 жыл бұрын
Its not necessary. You can have the 2 smart contracts in different files
@Lion-eh8pd
@Lion-eh8pd 4 жыл бұрын
How I can do it (without using import keyword) please explain me..
@EatTheBlocks
@EatTheBlocks 4 жыл бұрын
@@Lion-eh8pd you have to use the import keyword if you put your smart contracts in different files
@Lion-eh8pd
@Lion-eh8pd 4 жыл бұрын
Ohh ok 👍.
@shubh_1999
@shubh_1999 4 жыл бұрын
What if I want to return a user defined data type in Contract A from Contract B? So like you wrote returns(string memory) in callHelloWorld() what if I want to return Pilot[ ] Struct object from contract B? Surely I cannot just write returns(struct memory) or even returns(b.Pilot storage). What is the probable solution?
@dennisgonzales9521
@dennisgonzales9521 4 жыл бұрын
destructure your struct and return it
@deevocg6692
@deevocg6692 4 жыл бұрын
What does renounce ownership means on a contract and transfer ownership? It that a function to scam on liquidity pool?
@EatTheBlocks
@EatTheBlocks 4 жыл бұрын
this is not a feature of Solidity, it's implementation specific.
@thealpha_9
@thealpha_9 2 жыл бұрын
But how to call functions of a already deployed contract? Meaning there is no way to import the file like you are doing.
@danielemartinelli2700
@danielemartinelli2700 4 жыл бұрын
hello there ! Question: Can I call a function stored in another contract (contract B), without importing contract B in my contract "import "./contractB.sol" ? I would like to call a function in another contract just by knowing the contract B address
@su4per2star0
@su4per2star0 4 жыл бұрын
from solidity docs... .call(bytes memory), .delegatecall(bytes memory) and .staticcall(bytes memory) In order to interface with contracts that do not adhere to the ABI, or to get more direct control over the encoding, the functions call, delegatecall and staticcall are provided. They all take a single bytes memory parameter and return the success condition (as a bool) and the returned data (bytes memory). The functions abi.encode, abi.encodePacked, abi.encodeWithSelector and abi.encodeWithSignature can be used to encode structured data. Example: bytes memory payload = abi.encodeWithSignature("register(string)", "MyName"); (bool success, bytes memory returnData) = address(nameReg).call(payload); require(success); Disclaimer: All three functions call, delegatecall and staticcall are very low-level functions and should only be used as a last resort as they break the type-safety of Solidity.
@kishorepantra9769
@kishorepantra9769 3 жыл бұрын
i have given the same code as you but the contract key word is not working for interface it is throwing error . Only when i change it to interface it is working //SPDX-License-Identifier: MIT pragma solidity ^0.7.0; contract InterfaceB { function helloWorld() external pure returns(string memory); } contract B { function helloWorld() external pure returns(string memory){ return 'Hello Wrld'; } } error : browser/ContractB.sol:6:1: TypeError: Contract "InterfaceB" should be marked as abstract. contract InterfaceB { ^ (Relevant source part starts here and spans across multiple lines). browser/ContractB.sol:7:5: Missing implementation: function helloWorld() external pure returns(string m browser/ContractB.sol:7:5: TypeError: Functions without implementation must be marked virtual. function helloWorld() external pure returns(string memory); ^--
@atifraza5700
@atifraza5700 2 жыл бұрын
Can someone pls explain the line B b = B(addressB);
@MuhammadAli-qu1ot
@MuhammadAli-qu1ot 3 жыл бұрын
msg.sender.transfer(100); this also gives the same error as the a.transfer(100). Meaning that msg.sender isnt of address payable type.
@VishambarPandey
@VishambarPandey 3 жыл бұрын
Now we need to import like this import './ContractB.sol' Else it gives error.
@Tijdperkzuid
@Tijdperkzuid 2 жыл бұрын
Great video. only 1 change I like to see. Use dark theme please. my eyes hurting
@muqaddaszeb5870
@muqaddaszeb5870 3 жыл бұрын
i did not understand the working of setaddress function can someone help me?
@cold-as-ice
@cold-as-ice 3 жыл бұрын
Receives the address as a parameter and attaches it to a globally defined address parameter.
@rafaelosaka3254
@rafaelosaka3254 3 жыл бұрын
hi, I pay you 0.5 bnb to teach me how to make a multi file contract
@aaaliii4u
@aaaliii4u 2 жыл бұрын
you need to do this: import './ContractB.sol';
The IMPOSSIBLE Puzzle..
00:55
Stokes Twins
Рет қаралды 141 МЛН
HELP!!!
00:46
Natan por Aí
Рет қаралды 67 МЛН
1, 2, 3, 4, 5, 6, 7, 8, 9 🙈⚽️
00:46
Celine Dept
Рет қаралды 102 МЛН
Smart Contract Tutorial - Vending Machine Smart Contract in Solidity
34:34
Solidity Tutorial: Library
7:29
EatTheBlocks
Рет қаралды 9 М.
Accessing Private Data | Hack Solidity (0.6)
17:13
Smart Contract Programmer
Рет қаралды 20 М.
Solidity Tutorial: Memory vs Storage
7:40
EatTheBlocks
Рет қаралды 20 М.
Transfer ERC20 token from your Solidity smart contract
7:40
Artur Chmaro
Рет қаралды 46 М.