SlideShare a Scribd company logo
+ 9 1 9 5 0 1 7 0 7 7 4 1 T U T O R I A L S D I A R Y
S O L I D I T Y
F U N C T I O N C A L L S
+ 9 1 9 5 0 1 7 0 7 7 4 1 T U T O R I A L S D I A R Y
confidential @Tutorials Diary  | www.tutorialsdiary.com
How we can do ?
How a function in
another contract can
be called ?
+ 9 1 9 5 0 1 7 0 7 7 4 1 T U T O R I A L S D I A R Y
confidential @Tutorials Diary  | www.tutorialsdiary.com
Function Calls
There are mainly three ways to call function between contracts.
contractA = contractA(address)
contractA = new contractA()
require(_add.call(bytes4(keccak256("f(datatype)")),value));
+ 9 1 9 5 0 1 7 0 7 7 4 1 T U T O R I A L S D I A R Y
confidential @Tutorials Diary  | www.tutorialsdiary.com
Function Calls
contractA = new contractA()
pragma solidity ^ 0.4.20;
contract member{
uint age;
function setAge(uint _age){ age=_age; }
function getAge() public returns(uint){ return age; }
}
contract teacher{
function set() public{
member m=new member();
m.setAge(12);
}
}
+ 9 1 9 5 0 1 7 0 7 7 4 1 T U T O R I A L S D I A R Y
confidential @Tutorials Diary  | www.tutorialsdiary.com
Function Calls
contractA = contractA(address)
pragma solidity ^ 0.4.20;
contract member{
uint age;
function setAge(uint _age){ age=_age; }
function getAge() public returns(uint){ return age; }
}
contract teacher{
function set(address _add) public{
member m1=member(_add);
m1.setAge(14);
}
}
+ 9 1 9 5 0 1 7 0 7 7 4 1 T U T O R I A L S D I A R Y
confidential @Tutorials Diary  | www.tutorialsdiary.com
Function Calls
require(_add.call(bytes4(keccak256("f(datatype)")),value));
pragma solidity ^ 0.4.20;
contract member{
uint age;
function setAge(uint _age){ age=_age; }
function getAge() public returns(uint){ return age; }
}
contract teacher{
function set(address _add)public{
require(_add.call(bytes4(keccak256("setAge(uint256)")),12));
}
}

More Related Content

Similar to Solidity Tutorials- Function call in solidity

Working effectively with legacy code
Working effectively with legacy codeWorking effectively with legacy code
Working effectively with legacy code
ShriKant Vashishtha
 
SECTION D2)Display the item number and total cost for each order l.docx
SECTION D2)Display the item number and total cost for each order l.docxSECTION D2)Display the item number and total cost for each order l.docx
SECTION D2)Display the item number and total cost for each order l.docx
kenjordan97598
 
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Mario Fusco
 
1. DSA - Introduction.pptx
1. DSA - Introduction.pptx1. DSA - Introduction.pptx
1. DSA - Introduction.pptx
hara69
 

Similar to Solidity Tutorials- Function call in solidity (20)

Inheritance in solidity
Inheritance in solidityInheritance in solidity
Inheritance in solidity
 
Interface in solidity
Interface in solidityInterface in solidity
Interface in solidity
 
Constructor in solidity
Constructor in solidityConstructor in solidity
Constructor in solidity
 
enum_comp_exercicio01.docx
enum_comp_exercicio01.docxenum_comp_exercicio01.docx
enum_comp_exercicio01.docx
 
Java beginners meetup: Introduction to class and application design
Java beginners meetup: Introduction to class and application designJava beginners meetup: Introduction to class and application design
Java beginners meetup: Introduction to class and application design
 
Oop concept in c++ by MUhammed Thanveer Melayi
Oop concept in c++ by MUhammed Thanveer MelayiOop concept in c++ by MUhammed Thanveer Melayi
Oop concept in c++ by MUhammed Thanveer Melayi
 
Refactoring Example
Refactoring ExampleRefactoring Example
Refactoring Example
 
Combatendo code smells em Java
Combatendo code smells em Java Combatendo code smells em Java
Combatendo code smells em Java
 
[C++ korea] effective modern c++ study item 5 prefer auto to explicit type de...
[C++ korea] effective modern c++ study item 5 prefer auto to explicit type de...[C++ korea] effective modern c++ study item 5 prefer auto to explicit type de...
[C++ korea] effective modern c++ study item 5 prefer auto to explicit type de...
 
Creating a Whatsapp Clone - Part IX.pdf
Creating a Whatsapp Clone - Part IX.pdfCreating a Whatsapp Clone - Part IX.pdf
Creating a Whatsapp Clone - Part IX.pdf
 
Working effectively with legacy code
Working effectively with legacy codeWorking effectively with legacy code
Working effectively with legacy code
 
SECTION D2)Display the item number and total cost for each order l.docx
SECTION D2)Display the item number and total cost for each order l.docxSECTION D2)Display the item number and total cost for each order l.docx
SECTION D2)Display the item number and total cost for each order l.docx
 
SANER 2019 Most Influential Paper Talk
SANER 2019 Most Influential Paper TalkSANER 2019 Most Influential Paper Talk
SANER 2019 Most Influential Paper Talk
 
What's new in C# 6 - NetPonto Porto 20160116
What's new in C# 6  - NetPonto Porto 20160116What's new in C# 6  - NetPonto Porto 20160116
What's new in C# 6 - NetPonto Porto 20160116
 
2011 nri-pratiques tests-avancees
2011 nri-pratiques tests-avancees2011 nri-pratiques tests-avancees
2011 nri-pratiques tests-avancees
 
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...
 
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
 
1. DSA - Introduction.pptx
1. DSA - Introduction.pptx1. DSA - Introduction.pptx
1. DSA - Introduction.pptx
 
ThreeTen
ThreeTenThreeTen
ThreeTen
 
Smart Contract samples
Smart Contract samplesSmart Contract samples
Smart Contract samples
 

More from Tutorials Diary (6)

Solidity Tutorials- Difference between msg.sender and tx.origin
Solidity Tutorials- Difference between msg.sender and tx.originSolidity Tutorials- Difference between msg.sender and tx.origin
Solidity Tutorials- Difference between msg.sender and tx.origin
 
Solidity Tutorials- Libraries in solidity
Solidity Tutorials- Libraries in soliditySolidity Tutorials- Libraries in solidity
Solidity Tutorials- Libraries in solidity
 
Solidity low level logging
Solidity low level loggingSolidity low level logging
Solidity low level logging
 
Solidity- Error Handling
Solidity- Error HandlingSolidity- Error Handling
Solidity- Error Handling
 
Blockchain Introduction
Blockchain IntroductionBlockchain Introduction
Blockchain Introduction
 
Blockchain Webinar
Blockchain WebinarBlockchain Webinar
Blockchain Webinar
 

Recently uploaded

Recently uploaded (20)

AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101
 
Server-Driven User Interface (SDUI) at Priceline
Server-Driven User Interface (SDUI) at PricelineServer-Driven User Interface (SDUI) at Priceline
Server-Driven User Interface (SDUI) at Priceline
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Transforming The New York Times: Empowering Evolution through UX
Transforming The New York Times: Empowering Evolution through UXTransforming The New York Times: Empowering Evolution through UX
Transforming The New York Times: Empowering Evolution through UX
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System Strategy
 
Introduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG EvaluationIntroduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG Evaluation
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 

Solidity Tutorials- Function call in solidity

  • 1. + 9 1 9 5 0 1 7 0 7 7 4 1 T U T O R I A L S D I A R Y S O L I D I T Y F U N C T I O N C A L L S
  • 2. + 9 1 9 5 0 1 7 0 7 7 4 1 T U T O R I A L S D I A R Y confidential @Tutorials Diary  | www.tutorialsdiary.com How we can do ? How a function in another contract can be called ?
  • 3. + 9 1 9 5 0 1 7 0 7 7 4 1 T U T O R I A L S D I A R Y confidential @Tutorials Diary  | www.tutorialsdiary.com Function Calls There are mainly three ways to call function between contracts. contractA = contractA(address) contractA = new contractA() require(_add.call(bytes4(keccak256("f(datatype)")),value));
  • 4. + 9 1 9 5 0 1 7 0 7 7 4 1 T U T O R I A L S D I A R Y confidential @Tutorials Diary  | www.tutorialsdiary.com Function Calls contractA = new contractA() pragma solidity ^ 0.4.20; contract member{ uint age; function setAge(uint _age){ age=_age; } function getAge() public returns(uint){ return age; } } contract teacher{ function set() public{ member m=new member(); m.setAge(12); } }
  • 5. + 9 1 9 5 0 1 7 0 7 7 4 1 T U T O R I A L S D I A R Y confidential @Tutorials Diary  | www.tutorialsdiary.com Function Calls contractA = contractA(address) pragma solidity ^ 0.4.20; contract member{ uint age; function setAge(uint _age){ age=_age; } function getAge() public returns(uint){ return age; } } contract teacher{ function set(address _add) public{ member m1=member(_add); m1.setAge(14); } }
  • 6. + 9 1 9 5 0 1 7 0 7 7 4 1 T U T O R I A L S D I A R Y confidential @Tutorials Diary  | www.tutorialsdiary.com Function Calls require(_add.call(bytes4(keccak256("f(datatype)")),value)); pragma solidity ^ 0.4.20; contract member{ uint age; function setAge(uint _age){ age=_age; } function getAge() public returns(uint){ return age; } } contract teacher{ function set(address _add)public{ require(_add.call(bytes4(keccak256("setAge(uint256)")),12)); } }