일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- 스마트컨트렉트테스트
- nestjs 튜토리얼
- 프록시배포구조
- 깃허브명령어
- ethers type
- ambiguous function description
- chainlink 설명
- 스마트컨트렉트 예약어 함수이름 중복
- git rebase
- vue기초
- ethers
- nest.js설명
- 스마트컨트렉트프록시
- 스마트컨트렉트 함수이름 중복 호출
- 머신러닝기초
- 컨트렉트 배포 자동화
- SBT표준
- 스마트 컨트렉트 함수이름 중복
- 컨트렉트 동일한 함수이름 호출
- 체인의정석
- 러스트 기초 학습
- 러스트기초
- ethers v6
- Vue.js
- Vue
- ethers websocket
- rust 기초
- 러스트 기초
- ethers typescript
- multicall
Archives
- Today
- Total
체인의정석
DelegateCall에서 값을 가져오는 케이스 본문
728x90
반응형
1. 조회함수의 경우
To get the return value you should add callStatic to it.
> const shareTokenAddress = await liqminter.connect(actorA).callStatic.createPair([...])
callStatic is a read-only operation and will not consume any Ether. It simulates what would happen in a transaction, but discards all the state changes when it is done.
2. 이벤트를 쓰는 경우
You need to use Events. Here is an idea:
const tx = await contract.transfer(...args); // 100ms
const rc = await tx.wait(); // 0ms, as tx is already confirmed
const event = rc.events.find(event => event.event === 'Transfer');
const [from, to, value] = event.args;
console.log(from, to, value);
Check it out https://ethereum.stackexchange.com/a/119856/92472
이벤트를 써서 체크하는 방법이 더 좋아보긴 한다.
Do you try to use abi.decode function of Solidity.
In the below example, contract B calls setName of contract A, then decodes the result by using abi.decode function.
contract A {
string public name;
constructor(string memory tokenName) public {
name = tokenName;
}
function setName(string memory newName) public returns ( string memory){
name = newName;
return newName;
}
}
contract B {
event Log(string msg);
string public myName;
function call(address addr, string memory newName) public {
bytes memory payload = abi.encodeWithSignature("setName(string)", newName);
(bool success, bytes memory result)= addr.call(payload);
// Decode data
string memory name = abi.decode(result, (string));
myName = name;
emit Log(name);
}
}
3. decode 써서 로그 기록으로 남기기
728x90
반응형
'블록체인 > Solidity' 카테고리의 다른 글
이벤트 로그에 구조체 데이터 넣기, 이벤트 로그 작성하기 (0) | 2022.07.13 |
---|---|
delegateCall에서의 상태변화 가능여부 및 사용하면 안되는 이유 (0) | 2022.07.08 |
하나의 컨트렉트를 여러개로 분리해서 만들 때의 주의 사항 (0) | 2022.07.07 |
Warning: Return value of low-level calls not used (0) | 2022.07.06 |
Solidity constants vs immutable 차이 (0) | 2022.07.06 |
Comments