가스 견적 산출
EstimateGas(tx map[string]interface{}) (string, error) 트랜잭션을 완료하는 데 필요한 가스 양의 추정치를 생성하여 반환합니다.
파라미터
| 이름 | 타입 | 필수 | 설명 |
|---|---|---|---|
tx | map[string]interface{} | ✓ | 트랜잭션 객체 (수신자, 데이터, 금액) |
반환값
타입:
string 추정된 가스 양 (16진수)
예제
전송 비용 견적
tx := map[string]interface{}{
"to": "0x...",
"value": "0x1",
}
gas, _ := rpc.EstimateGas(tx)
fmt.Println("Gas needed:", gas)